Examples of RadixOption


Examples of com.cburch.logisim.circuit.RadixOption

    }

    @Override
    public void draw(Graphics g) {
      Value v = canvas.getCircuitState().getValue(wire.getEnd0());
      RadixOption radix1 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX1.get());
      RadixOption radix2 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX2.get());
      if (radix1 == null) radix1 = RadixOption.RADIX_2;
      String vStr = radix1.toString(v);
      if (radix2 != null && v.getWidth() > 1) {
        vStr += " / " + radix2.toString(v);
      }
     
      FontMetrics fm = g.getFontMetrics();
      g.setColor(caretColor);
      g.fillRect(x + 2, y + 2, fm.stringWidth(vStr) + 4,
View Full Code Here

Examples of com.cburch.logisim.circuit.RadixOption

 
  static void paintValue(InstancePainter painter, Value value) {
    Graphics g = painter.getGraphics();
    Bounds bds = painter.getBounds(); // intentionally with no graphics object - we don't want label included

    RadixOption radix = painter.getAttributeValue(RadixOption.ATTRIBUTE);
    if (radix == null || radix == RadixOption.RADIX_2) {
      int x = bds.getX();
      int y = bds.getY();
      int wid = value.getWidth();
      if (wid == 0) {
        x += bds.getWidth() / 2;
        y += bds.getHeight() / 2;
        GraphicsUtil.switchToWidth(g, 2);
        g.drawLine(x - 4, y, x + 4, y);
        return;
      }
      int x0 = bds.getX() + bds.getWidth() - 5;
      int compWidth = wid * 10;
      if (compWidth < bds.getWidth() - 3) {
        x0 = bds.getX() + (bds.getWidth() + compWidth) / 2 - 5;
      }
      int cx = x0;
      int cy = bds.getY() + bds.getHeight() - 12;
      int cur = 0;
      for (int k = 0; k < wid; k++) {
        GraphicsUtil.drawCenteredText(g,
          value.get(k).toDisplayString(), cx, cy);
        ++cur;
        if (cur == 8) {
          cur = 0;
          cx = x0;
          cy -= 20;
        } else {
          cx -= 10;
        }
      }
    } else {
      String text = radix.toString(value);
      GraphicsUtil.drawCenteredText(g, text,
          bds.getX() + bds.getWidth() / 2,
          bds.getY() + bds.getHeight() / 2);
    }
  }
View Full Code Here

Examples of com.cburch.logisim.circuit.RadixOption

        }

        @Override
        public void draw(Graphics g) {
            Value v = canvas.getCircuitState().getValue(wire.getEnd0());
            RadixOption radix1 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX1.get());
            RadixOption radix2 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX2.get());
            if (radix1 == null) {
                radix1 = RadixOption.RADIX_2;
            }

            String vStr = radix1.toString(v);
            if (radix2 != null && v.getWidth() > 1) {
                vStr += " / " + radix2.toString(v);
            }

            FontMetrics fm = g.getFontMetrics();
            g.setColor(caretColor);
            g.fillRect(x + 2, y + 2, fm.stringWidth(vStr) + 4,
View Full Code Here

Examples of com.cburch.logisim.circuit.RadixOption

    static void paintValue(InstancePainter painter, Value value) {
        Graphics g = painter.getGraphics();
        // intentionally with no graphics object - we don't want label included
        Bounds bds = painter.getBounds();

        RadixOption radix = painter.getAttributeValue(RadixOption.ATTRIBUTE);
        if (radix == null || radix == RadixOption.RADIX_2) {
            int x = bds.getX();
            int y = bds.getY();
            int wid = value.getWidth();
            if (wid == 0) {
                x += bds.getWidth() / 2;
                y += bds.getHeight() / 2;
                GraphicsUtil.switchToWidth(g, 2);
                g.drawLine(x - 4, y, x + 4, y);
                return;
            }
            int x0 = bds.getX() + bds.getWidth() - 5;
            int compWidth = wid * 10;
            if (compWidth < bds.getWidth() - 3) {
                x0 = bds.getX() + (bds.getWidth() + compWidth) / 2 - 5;
            }
            int cx = x0;
            int cy = bds.getY() + bds.getHeight() - 12;
            int cur = 0;
            for (int k = 0; k < wid; k++) {
                GraphicsUtil.drawCenteredText(g,
                    value.get(k).toDisplayString(), cx, cy);
                ++cur;
                if (cur == 8) {
                    cur = 0;
                    cx = x0;
                    cy -= 20;
                } else {
                    cx -= 10;
                }
            }
        } else {
            String text = radix.toString(value);
            GraphicsUtil.drawCenteredText(g, text,
                    bds.getX() + bds.getWidth() / 2,
                    bds.getY() + bds.getHeight() / 2);
        }
    }
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.