Examples of Graphics


Examples of java.awt.Graphics

    Bounds bds = painter.getBounds();
    BitWidth dataWidth = painter.getAttributeValue(StdAttr.WIDTH);
    int width = dataWidth == null ? 8 : dataWidth.getWidth();
    int len = (width + 3) / 4;

    Graphics g = painter.getGraphics();
    g.setColor(Color.RED);
    if (len > 4) {
      g.drawRect(bds.getX(), bds.getY() + 3, bds.getWidth(), 25);
    } else {
      int wid = 7 * len + 2;
      g.drawRect(bds.getX() + (bds.getWidth() - wid) / 2, bds.getY() + 4, wid, 15);
    }
    g.setColor(Color.BLACK);
  }
View Full Code Here

Examples of java.awt.Graphics

        g.fillRect(1, 1, 22, 22);
      }

      // draw tool icon
      g.setColor(Color.BLACK);
      Graphics g_copy = g.create();
      ComponentDrawContext c = new ComponentDrawContext(destination,
          null, null, g, g_copy);
      tool.paintIcon(c, 2, 2);
      g_copy.dispose();
    }
View Full Code Here

Examples of java.awt.Graphics

    setIconNames("nandGate.gif", "nandGateRect.gif", "dinNandGate.gif");
  }

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

Examples of java.awt.Graphics

    return XorGate.FACTORY.getRectangularLabel(attrs);
  }
 
  @Override
  public void paintIconShaped(InstancePainter painter) {
    Graphics g = painter.getGraphics();
    GraphicsUtil.drawCenteredArc(g,   0, - 5, 22, -9053);
    GraphicsUtil.drawCenteredArc(g,   0, 23, 2290, -53);
    GraphicsUtil.drawCenteredArc(g,  -89, 16, -30, 60);
    GraphicsUtil.drawCenteredArc(g, -109, 16, -30, 60);
    g.drawOval(16, 8, 4, 4);
  }
View Full Code Here

Examples of java.awt.Graphics

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

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

Examples of java.awt.Graphics

    String text = attrs.getText();
    if (text == null || text.equals("")) return;
   
    int halign = attrs.getHorizontalAlign();
    int valign = attrs.getVerticalAlign();
    Graphics g = painter.getGraphics();
    Font old = g.getFont();
    g.setFont(attrs.getFont());
    GraphicsUtil.drawText(g, text, 0, 0, halign, valign);
   
    String textTrim = text.endsWith(" ") ? text.substring(0, text.length() - 1) : text;
    Bounds newBds;
    if (textTrim.equals("")) {
      newBds = Bounds.EMPTY_BOUNDS;
    } else {
      Rectangle bdsOut = GraphicsUtil.getTextBounds(g, textTrim, 0, 0,
          halign, valign);
      newBds = Bounds.create(bdsOut).expand(4);
    }
    if (attrs.setOffsetBounds(newBds)) {
      Instance instance = painter.getInstance();
      if (instance != null) instance.recomputeBounds();
    }
       
    g.setFont(old);
  }
View Full Code Here

Examples of java.awt.Graphics

  @Override
  public void paintInstance(InstancePainter painter) {
    Location loc = painter.getLocation();
    int x = loc.getX();
    int y = loc.getY();
    Graphics g = painter.getGraphics();
    g.translate(x, y);
    g.setColor(Color.BLACK);
    paintGhost(painter);
    g.translate(-x, -y);
  }
View Full Code Here

Examples of java.awt.Graphics

      g.fillRect(BORDER, BORDER, dim.width, dim.height);
      GraphicsUtil.switchToWidth(g, 1);
      g.setColor(defaultColor);
    }

    Graphics g2 = g.create();
    g2.translate(BORDER, BORDER);
    item.paintIcon(ToolbarButton.this, g2);
    g2.dispose();

    // draw selection indicator
    if (toolbar.getToolbarModel().isSelected(item)) {
      Dimension dim = item.getDimension(toolbar.getOrientation());
      GraphicsUtil.switchToWidth(g, 2);
View Full Code Here

Examples of java.awt.Graphics

  }
 
  @Override
  protected void paintForeground(Graphics g) {
    double zoom = grid.getZoomFactor();
    Graphics gScaled = g.create();
    if (zoom != 1.0 && zoom != 0.0 && gScaled instanceof Graphics2D) {
      ((Graphics2D) gScaled).scale(zoom, zoom);
    }
    super.paintForeground(gScaled);
    gScaled.dispose();
  }
View Full Code Here

Examples of java.awt.Graphics

        .expand(BORDER_SIZE);
      int width = (int) Math.round(bds.getWidth() * scale);
      int height = (int) Math.round(bds.getHeight() * scale);
      BufferedImage img = new BufferedImage(width, height,
          BufferedImage.TYPE_INT_RGB);
      Graphics base = img.getGraphics();
      Graphics g = base.create();
      g.setColor(Color.white);
      g.fillRect(0, 0, width, height);
      g.setColor(Color.black);
      if (g instanceof Graphics2D) {
        ((Graphics2D) g).scale(scale, scale);
        ((Graphics2D) g).translate(-bds.getX(), -bds.getY());
      } else {
        JOptionPane.showMessageDialog(frame,
            Strings.get("couldNotCreateImage"));
        monitor.close();
      }

      CircuitState circuitState = canvas.getProject().getCircuitState(circuit);
      ComponentDrawContext context = new ComponentDrawContext(canvas,
          circuit, circuitState, base, g, printerView);
      circuit.draw(context, null);

      File where;
      if (dest.isDirectory()) {
        where = new File(dest, circuit.getName() + filter.extensions[0]);
      } else if (filter.accept(dest)) {
        where = dest;
      } else {
        String newName = dest.getName() + filter.extensions[0];
        where = new File(dest.getParentFile(), newName);
      }
      try {
        switch (filter.type) {
        case FORMAT_GIF: GifEncoder.toFile(img, where, monitor); break;
        case FORMAT_PNG: ImageIO.write(img, "PNG", where); break;
        case FORMAT_JPG: ImageIO.write(img, "JPEG", where); break;
        }
      } catch (Exception e) {
        JOptionPane.showMessageDialog(frame,
            Strings.get("couldNotCreateFile"));
        monitor.close();
        return;
      }
      g.dispose();
      monitor.close();
    }
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.