Examples of Graphics


Examples of java.awt.Graphics

   
    Bounds bds = painter.getBounds();
    int x = bds.getX() + 5;
    int y = bds.getY();

    Graphics g = painter.getGraphics();
    Color onColor = painter.getAttributeValue(Io.ATTR_ON_COLOR);
    Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
    Color bgColor = painter.getAttributeValue(Io.ATTR_BACKGROUND);
    if (painter.shouldDrawColor() && bgColor.getAlpha() != 0) {
      g.setColor(bgColor);
      g.fillRect(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
      g.setColor(Color.BLACK);
    }
    painter.drawBounds();
    g.setColor(Color.DARK_GRAY);
    for (int i = 0; i <= 7; i++) {
      if (painter.getShowState()) {
        g.setColor(((summ >> i) & 1) == desired ? onColor : offColor);
      }
      if (i < 7) {
        Bounds seg = SEGMENTS[i];
        g.fillRect(x + seg.getX(), y + seg.getY(), seg.getWidth(), seg.getHeight());
      } else {
        g.fillOval(x + 28, y + 48, 5, 5); // draw decimal point
      }
    }
    painter.drawPorts();
  }
View Full Code Here

Examples of java.awt.Graphics

    }
  }

  @Override
  public void paintInstance(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Direction facing = painter.getAttributeValue(StdAttr.FACING);

    painter.drawBounds();
    Bounds bds = painter.getBounds();
    g.setColor(Color.GRAY);
    int x0;
    int y0;
    int halign;
    if (facing == Direction.WEST) {
      x0 = bds.getX() + bds.getWidth() - 3;
      y0 = bds.getY() + 15;
      halign = GraphicsUtil.H_RIGHT;
    } else if (facing == Direction.NORTH) {
      x0 = bds.getX() + 10;
      y0 = bds.getY() + bds.getHeight() - 2;
      halign = GraphicsUtil.H_CENTER;
    } else if (facing == Direction.SOUTH) {
      x0 = bds.getX() + 10;
      y0 = bds.getY() + 12;
      halign = GraphicsUtil.H_CENTER;
    } else {
      x0 = bds.getX() + 3;
      y0 = bds.getY() + 15;
      halign = GraphicsUtil.H_LEFT;
    }
    GraphicsUtil.drawText(g, "0", x0, y0, halign, GraphicsUtil.V_BASELINE);
    g.setColor(Color.BLACK);
    GraphicsUtil.drawCenteredText(g, "Pri",
        bds.getX() + bds.getWidth() / 2,
        bds.getY() + bds.getHeight() / 2);
    painter.drawPorts();
  }
View Full Code Here

Examples of java.awt.Graphics

    }
  }
 
  @Override
  public void paintGhost(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Bounds bds = painter.getBounds();
    GraphicsUtil.switchToWidth(g, 2);
    g.drawOval(bds.getX() + 1, bds.getY() + 1,
        bds.getWidth() - 2, bds.getHeight() - 2);
  }
View Full Code Here

Examples of java.awt.Graphics

  public void paintInstance(InstancePainter painter) {
    InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
    Value val = data == null ? Value.FALSE : (Value) data.getValue();
    Bounds bds = painter.getBounds().expand(-1);

    Graphics g = painter.getGraphics();
    if (painter.getShowState()) {
      Color onColor = painter.getAttributeValue(Io.ATTR_ON_COLOR);
      Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
      Boolean activ = painter.getAttributeValue(Io.ATTR_ACTIVE);
      Object desired = activ.booleanValue() ? Value.TRUE : Value.FALSE;
      g.setColor(val == desired ? onColor : offColor);
      g.fillOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
    }
    g.setColor(Color.BLACK);
    GraphicsUtil.switchToWidth(g, 2);
    g.drawOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
    GraphicsUtil.switchToWidth(g, 1);
    g.setColor(painter.getAttributeValue(Io.ATTR_LABEL_COLOR));
    painter.drawLabel();
    painter.drawPorts();
  }
View Full Code Here

Examples of java.awt.Graphics

    }
 
    @Override
    public void paint(InstancePainter painter) {
      Bounds bds = getBounds(painter);
      Graphics g = painter.getGraphics();
      g.setColor(Color.RED);
      g.drawRect(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
      g.setColor(Color.BLACK);
    }
View Full Code Here

Examples of java.awt.Graphics

  private PainterShaped() { }
 
  private static HashMap<Integer,int[]> INPUT_LENGTHS = new HashMap<Integer,int[]>();
 
  static void paintAnd(InstancePainter painter, int width, int height) {
    Graphics g = painter.getGraphics();
    GraphicsUtil.switchToWidth(g, 2);
    int[] xp = new int[] { -width / 2, -width + 1, -width + 1, -width / 2 };
    int[] yp = new int[] { -width / 2, -width / 2, width / 2, width / 2 };
    GraphicsUtil.drawCenteredArc(g, -width / 2, 0, width / 2, -90, 180);

    g.drawPolyline(xp, yp, 4);
    if (height > width) {
      g.drawLine(-width + 1, -height / 2, -width + 1, height / 2);
    }
  }
View Full Code Here

Examples of java.awt.Graphics

    ps[CS].setToolTip(Strings.getter("memCSTip"));
  }

  @Override
  public void paintInstance(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Bounds bds = painter.getBounds();

    // draw boundary
    painter.drawBounds();

    // draw contents
    if (painter.getShowState()) {
      MemState state = getState(painter);
      state.paint(painter.getGraphics(), bds.getX(), bds.getY());
    } else {
      BitWidth addr = painter.getAttributeValue(ADDR_ATTR);
      int addrBits = addr.getWidth();
      int bytes = 1 << addrBits;
      String label;
      if (this instanceof Rom) {
        if (addrBits >= 30) {
          label = StringUtil.format(Strings.get("romGigabyteLabel"), ""
              + (bytes >>> 30));
        } else if (addrBits >= 20) {
          label = StringUtil.format(Strings.get("romMegabyteLabel"), ""
              + (bytes >> 20));
        } else if (addrBits >= 10) {
          label = StringUtil.format(Strings.get("romKilobyteLabel"), ""
              + (bytes >> 10));
        } else {
          label = StringUtil.format(Strings.get("romByteLabel"), ""
              + bytes);
        }
      } else {
        if (addrBits >= 30) {
          label = StringUtil.format(Strings.get("ramGigabyteLabel"), ""
              + (bytes >>> 30));
        } else if (addrBits >= 20) {
          label = StringUtil.format(Strings.get("ramMegabyteLabel"), ""
              + (bytes >> 20));
        } else if (addrBits >= 10) {
          label = StringUtil.format(Strings.get("ramKilobyteLabel"), ""
              + (bytes >> 10));
        } else {
          label = StringUtil.format(Strings.get("ramByteLabel"), ""
              + bytes);
        }
      }
      GraphicsUtil.drawCenteredText(g, label, bds.getX() + bds.getWidth()
          / 2, bds.getY() + bds.getHeight() / 2);
    }

    // draw input and output ports
    painter.drawPort(DATA, Strings.get("ramDataLabel"), Direction.WEST);
    painter.drawPort(ADDR, Strings.get("ramAddrLabel"), Direction.EAST);
    g.setColor(Color.GRAY);
    painter.drawPort(CS, Strings.get("ramCSLabel"), Direction.SOUTH);
  }
View Full Code Here

Examples of java.awt.Graphics

    return isOdd ? "2k+1" : "=1";
  }

  @Override
  public void paintIconShaped(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    GraphicsUtil.drawCenteredArc(g,   2, -5, 22, -9053);
    GraphicsUtil.drawCenteredArc(g,   2, 23, 2290, -53);
    GraphicsUtil.drawCenteredArc(g, -109, 16, -30, 60);
    GraphicsUtil.drawCenteredArc(g, -129, 16, -30, 60);
  }
View Full Code Here

Examples of java.awt.Graphics

    state.setPort(OUT, Value.createKnown(dataWidth, data.value), DELAY);
  }

  @Override
  public void paintInstance(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    Bounds bds = painter.getBounds();
    RegisterData state = (RegisterData) painter.getData();
    BitWidth widthVal = painter.getAttributeValue(StdAttr.WIDTH);
    int width = widthVal == null ? 8 : widthVal.getWidth();

    // determine text to draw in label
    String a;
    String b = null;
    if (painter.getShowState()) {
      int val = state == null ? 0 : state.value;
      String str = StringUtil.toHexString(width, val);
      if (str.length() <= 4) {
        a = str;
      } else {
        int split = str.length() - 4;
        a = str.substring(0, split);
        b = str.substring(split);
      }
    } else {
      a = Strings.get("registerLabel");
      b = Strings.get("registerWidthLabel", "" + widthVal.getWidth());
    }

    // draw boundary, label
    painter.drawBounds();
    painter.drawLabel();

    // draw input and output ports
    if (b == null) {
      painter.drawPort(IN,  "D", Direction.EAST);
      painter.drawPort(OUT, "Q", Direction.WEST);
    } else {
      painter.drawPort(IN);
      painter.drawPort(OUT);
    }
    g.setColor(Color.GRAY);
    painter.drawPort(CLR, "0", Direction.SOUTH);
    painter.drawPort(EN, Strings.get("memEnableLabel"), Direction.EAST);
    g.setColor(Color.BLACK);
    painter.drawClock(CK, Direction.NORTH);

    // draw contents
    if (b == null) {
      GraphicsUtil.drawText(g, a, bds.getX() + 15, bds.getY() + 4,
View Full Code Here

Examples of java.awt.Graphics

  }
 
  @Override
  public void paintInstance(InstancePainter painter) {
    boolean showState = painter.getShowState();
    Graphics g = painter.getGraphics();
    painter.drawClock(CK, Direction.EAST);
    painter.drawBounds();
    painter.drawPort(CLR);
    painter.drawPort(RE);
    painter.drawPort(AVL);
    painter.drawPort(OUT);

    if (showState) {
      String str;
      int dispStart;
      int dispEnd;
      ArrayList<Integer> specials = new ArrayList<Integer>();
      FontMetrics fm = null;
      KeyboardData state = getKeyboardState(painter);
      synchronized(state) {
        str = state.toString();
        for (int i = state.getNextSpecial(0); i >= 0; i = state.getNextSpecial(i + 1)) {
          char c = state.getChar(i);
          specials.add(Integer.valueOf(c << 16 | i));
        }
        if (!state.isDisplayValid()) {
          fm = g.getFontMetrics(DEFAULT_FONT);
          state.updateDisplay(fm);
        }
        dispStart = state.getDisplayStart();
        dispEnd = state.getDisplayEnd();
      }
     
      if (str.length() > 0) {
        Bounds bds = painter.getBounds();
        drawBuffer(g, fm, str, dispStart, dispEnd, specials, bds);
      }
    } else {
      Bounds bds = painter.getBounds();
      int len = getBufferLength(painter.getAttributeValue(ATTR_BUFFER));
      String str = Strings.get("keybDesc", "" + len);
      FontMetrics fm = g.getFontMetrics();
      int x = bds.getX() + (WIDTH - fm.stringWidth(str)) / 2;
      int y = bds.getY() + (HEIGHT + fm.getAscent()) / 2;
      g.drawString(str, x, y);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.