Package java.awt

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


    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

    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

  }
 
  @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

    paintIconRectangular(painter);
  }
 
  @Override
  public void paintIconRectangular(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    g.setColor(Color.black);
    g.drawRect(1, 2, 16, 16);
    Font old = g.getFont();
    g.setFont(old.deriveFont(9.0f));
    GraphicsUtil.drawCenteredText(g, "2k", 96);
    GraphicsUtil.drawCenteredText(g, "+1", 9, 13);
    g.setFont(old);
  }
View Full Code Here

    }
   
    public void draw(InstancePainter painter) {
      KeyboardData data = getKeyboardState(painter);
      Bounds bds = painter.getInstance().getBounds();
      Graphics g = painter.getGraphics();
      FontMetrics fm = g.getFontMetrics(DEFAULT_FONT);

      String str;
      int cursor;
      int dispStart;
      synchronized(data) {
        str = data.toString();
        cursor = data.getCursorPosition();
        if (!data.isDisplayValid()) data.updateDisplay(fm);
        dispStart = data.getDisplayStart();
      }

      int asc = fm.getAscent();
      int x = bds.getX() + 8;
      if (dispStart > 0) {
        x += fm.stringWidth(str.charAt(0) + "m");
        x += fm.stringWidth(str.substring(dispStart, cursor));
      } else if (cursor >= str.length()) {
        x += fm.stringWidth(str);
      } else {
        x += fm.stringWidth(str.substring(0, cursor));
      }
      int y = bds.getY() + (bds.getHeight() + asc) / 2;
      g.drawLine(x, y - asc, x, y);
    }
View Full Code Here

    state.setPort(B_OUT, outs[1].not(), delay);
  }

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

    g.setColor(Color.GRAY);
    painter.drawPort(IN0);
    painter.drawPort(IN1);
    painter.drawPort(OUT);
    painter.drawPort(B_IN,  "b in",  Direction.NORTH);
    painter.drawPort(B_OUT, "b out", Direction.SOUTH);

    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    GraphicsUtil.switchToWidth(g, 2);
    g.setColor(Color.BLACK);
    g.drawLine(x - 15, y, x - 5, y);
    GraphicsUtil.switchToWidth(g, 1);
  }
View Full Code Here

    setIconNames("andGate.gif", "andGateRect.gif", "dinAndGate.gif");
  }

  @Override
  protected void paintIconShaped(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    int[] xp = new int[] { 10, 2, 2, 10 };
    int[] yp = new int[] { 2, 2, 18, 18 };
    g.drawPolyline(xp, yp, 4);
    GraphicsUtil.drawCenteredArc(g, 10, 10, 8, -90, 180);
  }
View Full Code Here

    if (columns == 0) {
      setPreferredSize(new Dimension(0, 0));
      return;
    }
   
    Graphics g = getGraphics();
    if (g == null) {
      cellHeight = 16;
      cellWidth = 24;
    } else {
      FontMetrics fm = g.getFontMetrics(HEAD_FONT);
      cellHeight = fm.getHeight();
      cellWidth = 24;
      for (int i = 0; i < columns; i++) {
        String header = sel.get(i).toShortString();
        cellWidth = Math.max(cellWidth, fm.stringWidth(header));
View Full Code Here

    state.setPort(C_OUT, outs[1], delay);
  }

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

    g.setColor(Color.GRAY);
    painter.drawPort(IN0);
    painter.drawPort(IN1);
    painter.drawPort(OUT);
    painter.drawPort(C_IN,  "c in",  Direction.NORTH);
    painter.drawPort(C_OUT, "c out", Direction.SOUTH);

    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    GraphicsUtil.switchToWidth(g, 2);
    g.setColor(Color.BLACK);
    g.drawLine(x - 15, y - 5, x - 5, y + 5);
    g.drawLine(x - 15, y + 5, x - 5, y - 5);
    GraphicsUtil.switchToWidth(g, 1);
  }
View Full Code Here

TOP

Related Classes of java.awt.Graphics

Copyright © 2018 www.massapicom. 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.