/** This method is invoked before the rendered image of the figure is composited. */ public void drawFigure(Graphics2D g) { AffineTransform savedTransform = null; if (get(TRANSFORM) != null) { savedTransform = g.getTransform(); g.transform(get(TRANSFORM)); } if (get(FILL_STYLE) != ODGConstants.FillStyle.NONE) { Paint paint = ODGAttributeKeys.getFillPaint(this); if (paint != null) { g.setPaint(paint); drawFill(g); } } if (get(STROKE_STYLE) != ODGConstants.StrokeStyle.NONE) { Paint paint = ODGAttributeKeys.getStrokePaint(this); if (paint != null) { g.setPaint(paint); g.setStroke(ODGAttributeKeys.getStroke(this)); drawStroke(g); } } if (get(TRANSFORM) != null) { g.setTransform(savedTransform); } }
/** * Paint a background for all groups and a round blue border and background when a cell is * selected. * * @param g2 the <tt>Graphics2D</tt> object through which we paint */ private void internalPaintComponent(Graphics2D g2) { Color borderColor = Color.GRAY; if (isSelected) { g2.setPaint( new GradientPaint( 0, 0, Constants.SELECTED_COLOR, 0, getHeight(), Constants.SELECTED_GRADIENT_COLOR)); borderColor = Constants.SELECTED_COLOR; } else if (treeNode instanceof GroupNode) { g2.setPaint( new GradientPaint( 0, 0, Constants.CONTACT_LIST_GROUP_BG_GRADIENT_COLOR, 0, getHeight(), Constants.CONTACT_LIST_GROUP_BG_COLOR)); borderColor = Constants.CONTACT_LIST_GROUP_BG_COLOR; } g2.fillRect(0, 0, getWidth(), getHeight()); g2.setColor(borderColor); g2.drawLine(0, 0, getWidth(), 0); g2.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1); }
/** * Render the View to the given graphic context. This implementation render the interior first, * then the outline. */ public void paint(Graphics2D g, Rectangle2D a) { if (!a.intersects(getBounds())) return; if (image != null) { // paint bitmap g.drawImage(image, text2ModelTr, null); // debug: g.setPaint(Color.red); g.draw(this.bounds); super.paint(g, a); // possibly paint framebox if non-null } else { // paint textlayout super.paint(g, a); // possibly paint framebox if non-null AffineTransform oldAT = g.getTransform(); // paint text in black g.setPaint(Color.black); // from now on, we work in Y-direct (<0) coordinates to avoid inextricable problems with font // being mirrored... g.transform(text2ModelTr); // also include rotation textLayout.draw(g, 0.0f, 0.0f); // [pending] ajouter un cadre si areDimensionsComputed (wysiwyg du pauvre) // get back to previous transform g.setTransform(oldAT); if (DEBUG) { g.setPaint(Color.red); g.draw(bounds); } } }
public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle2D rect = new Rectangle2D.Double(0, 0, getWidth() - 1, getHeight() - 1); g2.setPaint(Color.YELLOW); g2.fill(rect); g2.setPaint(Color.BLUE); g2.draw(rect); }
/** Draws the edge structure of the tree */ public void drawEdges(Graphics2D gg) { gg.setPaint(Color.black); Enumeration nodeList = argument.getBreadthFirstTraversal().elements(); // For each vertex... while (nodeList.hasMoreElements()) { // Get its edge list... TreeVertex vertex = (TreeVertex) nodeList.nextElement(); Enumeration edges = vertex.getEdgeList().elements(); // For each edge in the list... while (edges.hasMoreElements()) { TreeEdge edge = (TreeEdge) edges.nextElement(); // If we have several vertices on layer 0, only draw // edges for layers below that if (!(argument.isMultiRoots() && vertex.getLayer() == 0)) { // If the edge has been selected with the mouse, // use a thick line if (edge.isSelected()) { gg.setStroke(selectStroke); } gg.draw(edge.getShape(this)); // If we used a thick line, reset the stroke to normal // line for next edge. if (edge.isSelected()) { gg.setStroke(solidStroke); } TreeVertex edgeSource = edge.getDestVertex(); } } } }
/** paint the canvas into a image file of given width and height */ public void writeToImage(String s, int w, int h) { String ext; File f; try { ext = s.substring(s.lastIndexOf(".") + 1); f = new File(s); } catch (Exception e) { System.out.println(e); return; } if (!ext.equals("jpg") && !ext.equals("png")) { System.out.println("Cannot write to file: Illegal extension " + ext); return; } boolean opq = true; if (theOpaque != null) opq = theOpaque; BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setBackground(Color.white); g2.setPaint(Color.black); g2.setStroke(new BasicStroke(1)); g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); doBuffer(g2, true, new Rectangle(0, 0, w, h)); try { ImageIO.write(image, ext, f); } catch (Exception e) { System.out.println(e); } }
// draws the tree, starting from the given node, in the region with x values // ranging // from minX to maxX, with y value beginning at y, and next level at y + // yIncr. private void drawTree(Graphics2D g2, TreeNode<E> t, int minX, int maxX, int y, int yIncr) { // skip if empty if (t == null) return; // compute useful coordinates int x = (minX + maxX) / 2; int nextY = y + yIncr; // draw black lines g2.setPaint(Color.black); if (t.left != null) { int nextX = (minX + x) / 2; g2.draw(new Line2D.Double(x, y, nextX, nextY)); } if (t.right != null) { int nextX = (x + maxX) / 2; g2.draw(new Line2D.Double(x, y, nextX, nextY)); } // measure text FontMetrics font = g2.getFontMetrics(); String text = t.data + ""; int textHeight = font.getHeight(); int textWidth = font.stringWidth(text); // draw the box around the node Rectangle2D.Double box = new Rectangle2D.Double( x - textWidth / 2 - ARC_PAD, y - textHeight / 2 - ARC_PAD, textWidth + 2 * ARC_PAD, textHeight + 2 * ARC_PAD); Color c = new Color(187, 224, 227); g2.setPaint(c); g2.fill(box); // draw black border g2.setPaint(Color.black); g2.draw(box); // draw text g2.drawString(text, x - textWidth / 2, y + textHeight / 2); // draw children drawTree(g2, t.left, minX, x, nextY, yIncr); drawTree(g2, t.right, x, maxX, nextY, yIncr); }
private void shadeExt(Graphics2D g2, int r, int g, int b, int a) { g2.setPaint(new Color(r, g, b, a)); g2.fillRect(0, 0, iw, rect.y); /* _N_ */ g2.fillRect( rect.x + rect.width + 1, rect.y, iw - rect.x - rect.width - 1, rect.height + 1); /* E */ g2.fillRect(0, rect.y, rect.x, rect.height + 1); /* W */ g2.fillRect(0, rect.y + rect.height + 1, iw, ih - rect.y - rect.height - 1); /* _S_ */ }
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setPaint(BACKGROUND); g2.fill( new Rectangle2D.Float( 0f, 0f, (float) g2.getClipBounds().width, (float) g2.getClipBounds().height)); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); canvas.paint(g2); }
/** Draw vertices on top of the edge structure */ public void drawNodes(Graphics2D gg) { Enumeration nodeList = argument.getBreadthFirstTraversal().elements(); // Run through the traversal and draw each vertex // using an Ellipse2D // The draw point has been determined previously in // calcNodeCoords() while (nodeList.hasMoreElements()) { TreeVertex vertex = (TreeVertex) nodeList.nextElement(); // Don't draw virtual nodes if (vertex.isVirtual()) continue; // If tree is incomplete and we're on the top layer, skip it if (argument.isMultiRoots() && vertex.getLayer() == 0) continue; Point corner = vertex.getDrawPoint(); Shape node = new Ellipse2D.Float(corner.x, corner.y, NODE_DIAM, NODE_DIAM); vertex.setShape(node, this); // Fill the interior of the node with vertex's fillPaint gg.setPaint(vertex.fillPaint); gg.fill(node); // Draw the outline with vertex's outlinePaint; bold if selected gg.setPaint(vertex.outlinePaint); if (vertex.isSelected()) { gg.setStroke(selectStroke); } else { gg.setStroke(solidStroke); } gg.draw(node); // Draw the short label on top of the vertex gg.setPaint(vertex.textPaint); String shortLabelString = new String(vertex.getShortLabel()); if (shortLabelString.length() == 1) { gg.setFont(labelFont1); gg.drawString(shortLabelString, corner.x + NODE_DIAM / 4, corner.y + 3 * NODE_DIAM / 4); } else if (shortLabelString.length() == 2) { gg.setFont(labelFont2); gg.drawString(shortLabelString, corner.x + NODE_DIAM / 5, corner.y + 3 * NODE_DIAM / 4); } } }
public static BufferedImage cropImage(BufferedImage bi, int x, int y, int w, int h) { BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2.setPaint(Color.white); g2.fillRect(0, 0, w, h); g2.drawImage(bi, -x, -y, null); // this); g2.dispose(); return image; }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { icon.paintIcon(c, g, x, y); int w = getIconWidth(); int h = getIconHeight(); Graphics2D g2 = (Graphics2D) g; g2.setPaint(FOREGROUND); g2.translate(x, y); g2.fillRect(a, (h - b) / 2, w - a - a, b); g2.translate(-x, -y); }
public static BufferedImage tileImage(BufferedImage im, int width, int height) { GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice() .getDefaultConfiguration(); int transparency = Transparency.OPAQUE; // Transparency.BITMASK; BufferedImage compatible = gc.createCompatibleImage(width, height, transparency); Graphics2D g = (Graphics2D) compatible.getGraphics(); g.setPaint(new TexturePaint(im, new Rectangle(0, 0, im.getWidth(), im.getHeight()))); g.fillRect(0, 0, width, height); return compatible; }
public static BufferedImage scaleImage(BufferedImage bi, double scale) { int w1 = (int) (Math.round(scale * bi.getWidth())); int h1 = (int) (Math.round(scale * bi.getHeight())); BufferedImage image = new BufferedImage(w1, h1, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2.setPaint(Color.white); g2.fillRect(0, 0, w1, h1); g2.drawImage(bi, 0, 0, w1, h1, null); // this); g2.dispose(); return image; }
private void drawHorizontalGradient( Graphics2D g, float ratio1, float ratio2, Color c1, Color c2, Color c3, int w, int h) { int mid = (int) (ratio1 * w); int mid2 = (int) (ratio2 * w); if (mid > 0) { g.setPaint(getGradient((float) 0, (float) 0, c1, (float) mid, (float) 0, c2)); g.fillRect(0, 0, mid, h); } if (mid2 > 0) { g.setColor(c2); g.fillRect(mid, 0, mid2, h); } if (mid > 0) { g.setPaint( getGradient((float) mid + mid2, (float) 0, c2, (float) mid * 2 + mid2, (float) 0, c1)); g.fillRect(mid + mid2, 0, mid, h); } if (w - mid * 2 - mid2 > 0) { g.setPaint(getGradient((float) mid * 2 + mid2, (float) 0, c1, w, (float) 0, c3)); g.fillRect(mid * 2 + mid2, 0, w - mid * 2 - mid2, h); } }
private void drawVerticalGradient( Graphics2D g, float ratio1, float ratio2, Color c1, Color c2, Color c3, int w, int h) { int mid = (int) (ratio1 * h); int mid2 = (int) (ratio2 * h); if (mid > 0) { g.setPaint(getGradient((float) 0, (float) 0, c1, (float) 0, (float) mid, c2)); g.fillRect(0, 0, w, mid); } if (mid2 > 0) { g.setColor(c2); g.fillRect(0, mid, w, mid2); } if (mid > 0) { g.setPaint( getGradient((float) 0, (float) mid + mid2, c2, (float) 0, (float) mid * 2 + mid2, c1)); g.fillRect(0, mid + mid2, w, mid); } if (h - mid * 2 - mid2 > 0) { g.setPaint(getGradient((float) 0, (float) mid * 2 + mid2, c1, (float) 0, (float) h, c3)); g.fillRect(0, mid * 2 + mid2, w, h - mid * 2 - mid2); } }
private synchronized void doBuffer(Graphics2D g2, boolean opq, Rectangle rt) { origTransform = g2.getTransform(); if (opq && rt != null) g2.clearRect(rt.x, rt.y, rt.width, rt.height); g2.setPaint(origPaint); g2.setFont(origFont); g2.setStroke(origStroke); if (inBuffer) { // System.out.println("upps"); for (int i = 0; i < a1x.size(); i++) doPaint(g2, a1x.get(i), a2x.get(i)); origTransform = null; return; } for (int i = 0; i < a1.size(); i++) doPaint(g2, a1.get(i), a2.get(i)); origTransform = null; }
public static BufferedImage rotateImage(BufferedImage bi) { int w = bi.getWidth(); int h = bi.getHeight(); BufferedImage image = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2.setPaint(Color.white); // getBackground()); g2.fillRect(0, 0, h, w); g2.rotate(90 * Math.PI / 180); g2.drawImage(bi, 0, -h, w, h, null); // this); g2.dispose(); return image; }
/** * Overrides Step draw method. * * @param panel the drawing panel requesting the drawing * @param _g the graphics context on which to draw */ public void draw(DrawingPanel panel, Graphics _g) { if (track.trackerPanel == panel) { AutoTracker autoTracker = track.trackerPanel.getAutoTracker(); if (autoTracker.isInteracting(track)) return; } if (panel instanceof TrackerPanel) { TrackerPanel trackerPanel = (TrackerPanel) panel; super.draw(trackerPanel, _g); Graphics2D g = (Graphics2D) _g; if (isLabelVisible()) { TextLayout layout = textLayouts.get(trackerPanel); if (layout == null) return; Point p = getLayoutPosition(trackerPanel); Paint gpaint = g.getPaint(); Font gfont = g.getFont(); g.setPaint(footprint.getColor()); g.setFont(textLayoutFont); layout.draw(g, p.x, p.y); g.setPaint(gpaint); g.setFont(gfont); } } }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2 = (Graphics2D) g.create(); g2.setPaint(Objects.nonNull(c) ? c.getBackground() : Color.WHITE); g2.fillRect(x, y, getIconWidth(), getIconHeight()); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(ELLIPSE_COLOR); g2.translate(x, y); int size = list.size(); for (int i = 0; i < size; i++) { float alpha = isRunning ? (i + 1) / (float) size : .5f; g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); g2.fill(list.get(i)); } // g2.translate(-x, -y); g2.dispose(); }
/** * 选中时画背景 * * @param g2d */ @Override protected void paintSelection(Graphics2D g2d) { if (tree.getSelectionCount() > 0) { // Draw final selections final java.util.List<Rectangle> selections = getSelectionRects(); for (final Rectangle rect : selections) { g2d.setPaint(selectedBg); g2d.fill( new RoundRectangle2D.Double( rect.x + selectionShadeWidth, rect.y + selectionShadeWidth, rect.width - selectionShadeWidth * 2 - 1, rect.height - selectionShadeWidth * 2 - 1, 0, 0)); } } }
/** * Paints a custom gradient background for selected cells. * * @param g the <tt>Graphics</tt> object used for painting */ private void internalPaintComponent(Graphics g) { AntialiasingManager.activateAntialiasing(g); Graphics2D g2 = (Graphics2D) g; int width = getWidth(); int height = getHeight(); if (this.isSelected) { GradientPaint p = new GradientPaint( width / 2, 0, SELECTED_START_COLOR, width / 2, height, SELECTED_END_COLOR); g2.setPaint(p); g2.fillRoundRect(1, 1, width, height - 1, 7, 7); } g2.setColor(SELECTED_START_COLOR); g2.drawLine(0, height - 1, width, height - 1); }
/** * 鼠标经过画背景 * * @param g2d */ @Override protected void paintRolloverNodeHighlight(Graphics2D g2d) { if (tree.isEnabled() && highlightRolloverNode && rolloverRow != -1 && !tree.isRowSelected(rolloverRow)) { final Rectangle rect = isFullLineSelection() ? getFullRowBounds(rolloverRow) : tree.getRowBounds(rolloverRow); if (rect != null) { // final Composite old = LafUtils.setupAlphaComposite ( g2d, 0.35f ); g2d.setPaint(rolloverBg); g2d.fill( new RoundRectangle2D.Double( rect.x + selectionShadeWidth, rect.y + selectionShadeWidth, rect.width - selectionShadeWidth * 2 - 1, rect.height - selectionShadeWidth * 2 - 1, 0, 0)); // LafUtils.restoreComposite ( g2d, old ); } } }
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Dimension asz = this.getSize(); if (fullRefresh) { g2.clearRect(0, 0, asz.width, asz.height); fullRefresh = false; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); big.setColor(Color.black); offset.x = (int) (asz.width - iw) / 2; offset.y = (int) (asz.height - ih) / 2; big.drawImage(img, 0, 0, this); big.setPaint(Color.red); if ((rect.width > 0) && (rect.height > 0)) big.draw(rect); if (selected == 1) shadeExt(big, 0, 0, 0, 64); else if (selected == 2) { shadeExt(big, 0, 0, 0, 255); selected = 1; } g2.drawImage(bi, offset.x, offset.y, this); }
private synchronized void toBuffer(int s, Object a) { a1.add(s); a2.add(a); if (s == clear) { clearBuffer(); } if (s == opaque) theOpaque = (Boolean) a; if (s == setBackground) theBackground = (Color) a; if (inBuffer) return; if (isSetter(s)) return; Graphics g = getGraphics(); if (g == null) return; Graphics2D g2 = (Graphics2D) g; g2.setPaint(origPaint); g2.setFont(origFont); g2.setStroke(origStroke); for (int i = 0; i < a1.size() - 1; i++) { int s1 = a1.get(i); Object s2 = a2.get(i); if (isSetter(s1)) doPaint(g2, s1, s2); } doPaint((Graphics2D) g, s, a); }
// called whenever the TreeDisplay must be drawn on the screen public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Dimension d = getSize(); // draw white background g2.setPaint(Color.white); g2.fill(new Rectangle2D.Double(0, 0, d.width, d.height)); int depth = h(); if (root == null) // no tree to draw return; // hack to avoid division by zero, if only one level in tree if (depth == 1) depth = 2; // compute the size of the text FontMetrics font = g2.getFontMetrics(); TreeNode<E> leftmost = root; while (leftmost.left != null) leftmost = leftmost.left; TreeNode<E> rightmost = root; while (rightmost.right != null) rightmost = rightmost.right; int leftPad = font.stringWidth(leftmost.data + "") / 2; int rightPad = font.stringWidth(rightmost.data + "") / 2; int textHeight = font.getHeight(); // draw the actual tree drawTree( g2, root, leftPad + ARC_PAD, d.width - rightPad - ARC_PAD, textHeight / 2 + ARC_PAD, (d.height - textHeight - 2 * ARC_PAD) / (depth - 1)); }
// also clip, transform, composite, // public boolean isOpaque(){return false;}//theOpaque!=null&&theOpaque;} // --------------------------------------------------------- private void doPaint(Graphics2D g, int s, Object o) { // process an operation from the buffer // System.out.println(s); Object o1 = null, o2 = null, o3 = null, o4 = null, o5 = null, o6 = null, o7 = null, o8 = null, o9 = null, o10 = null, o11 = null; if (o instanceof Object[]) { Object[] a = (Object[]) o; if (a.length > 0) o1 = a[0]; if (a.length > 1) o2 = a[1]; if (a.length > 2) o3 = a[2]; if (a.length > 3) o4 = a[3]; if (a.length > 4) o5 = a[4]; if (a.length > 5) o6 = a[5]; if (a.length > 6) o7 = a[6]; if (a.length > 7) o8 = a[7]; if (a.length > 8) o9 = a[8]; if (a.length > 9) o10 = a[9]; if (a.length > 10) o11 = a[10]; } switch (s) { case clear: paintBackground(g, theBackground); break; // public void addRenderingHints(Map<?,?> hints) // {toBuffer("addRenderingHints",hints );} case addRenderingHints: g.addRenderingHints((Map<?, ?>) o); break; case clip1: g.clip((Shape) o); break; case draw1: g.draw((Shape) o); break; case draw3DRect: g.draw3DRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Boolean) o5); break; case drawGlyphVector: g.drawGlyphVector((GlyphVector) o1, (Float) o2, (Float) o3); break; case drawImage1: g.drawImage((BufferedImage) o1, (BufferedImageOp) o2, (Integer) o3, (Integer) o4); break; case drawImage2: g.drawImage((Image) o1, (AffineTransform) o2, (ImageObserver) o3); break; case drawRenderableImage: g.drawRenderableImage((RenderableImage) o1, (AffineTransform) o2); break; case drawRenderedImage: g.drawRenderedImage((RenderedImage) o1, (AffineTransform) o2); break; case drawString1: g.drawString((AttributedCharacterIterator) o1, (Float) o2, (Float) o3); break; case drawString2: g.drawString((AttributedCharacterIterator) o1, (Integer) o2, (Integer) o3); break; case drawString3: g.drawString((String) o1, (Float) o2, (Float) o3); break; case drawString4: g.drawString((String) o1, (Integer) o2, (Integer) o3); break; case fill: g.fill((Shape) o); break; case fill3DRect: g.fill3DRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Boolean) o5); break; case rotate1: g.rotate((Double) o); break; case rotate2: g.rotate((Double) o1, (Double) o2, (Double) o3); break; case scale1: g.scale((Double) o1, (Double) o2); break; case setBackground: g.setBackground( (Color) o); // paintBackground(g,(Color)o); /*super.setBackground((Color)o) ;*/ break; case setComposite: g.setComposite((Composite) o); break; case setPaint: g.setPaint((Paint) o); break; case setRenderingHint: g.setRenderingHint((RenderingHints.Key) o1, o2); break; case setRenderingHints: g.setRenderingHints((Map<?, ?>) o); break; case setStroke: g.setStroke((Stroke) o); break; case setTransform: g.setTransform(makeTransform(o)); break; case shear: g.shear((Double) o1, (Double) o2); break; case transform1: g.transform(makeTransform(o)); break; case translate1: g.translate((Double) o1, (Double) o2); break; case translate2: g.translate((Integer) o1, (Integer) o2); break; case clearRect: g.clearRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4); break; case copyArea: g.copyArea( (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6); break; case drawArc: g.drawArc( (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6); break; case drawBytes: g.drawBytes((byte[]) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5); break; case drawChars: g.drawChars((char[]) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5); break; case drawImage4: g.drawImage((Image) o1, (Integer) o2, (Integer) o3, (Color) o4, (ImageObserver) o5); break; case drawImage5: g.drawImage((Image) o1, (Integer) o2, (Integer) o3, (ImageObserver) o4); break; case drawImage6: g.drawImage( (Image) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Color) o6, (ImageObserver) o7); break; case drawImage7: g.drawImage( (Image) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (ImageObserver) o6); break; case drawImage8: g.drawImage( (Image) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6, (Integer) o7, (Integer) o8, (Integer) o9, (Color) o10, (ImageObserver) o11); break; case drawImage9: g.drawImage( (Image) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6, (Integer) o7, (Integer) o8, (Integer) o9, (ImageObserver) o10); break; case drawLine: g.drawLine((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4); break; case drawOval: g.drawOval((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4); break; case drawPolygon1: g.drawPolygon((int[]) o1, (int[]) o2, (Integer) o3); break; case drawPolygon2: g.drawPolygon((Polygon) o); break; case drawPolyline: g.drawPolyline((int[]) o1, (int[]) o2, (Integer) o3); break; case drawRect: g.drawRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4); break; case drawRoundRect: g.drawRoundRect( (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6); break; case fillArc: g.fillArc( (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6); break; case fillOval: g.fillOval((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4); break; // {toBuffer("fillPolygon",mkArg(xPoints, yPoints, nPoints) );} case fillPolygon1: g.fillPolygon((int[]) o1, (int[]) o2, (Integer) o3); break; case fillPolygon2: g.fillPolygon((Polygon) o); break; case fillRect: g.fillRect((Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4); break; case fillRoundRect: g.fillRoundRect( (Integer) o1, (Integer) o2, (Integer) o3, (Integer) o4, (Integer) o5, (Integer) o6); break; case setClip1: g.setClip((Shape) o); break; case setColor: g.setColor((Color) o); break; case setFont: g.setFont((Font) o); break; case setPaintMode: g.setPaintMode(); break; case setXORMode: g.setXORMode((Color) o); break; case opaque: super.setOpaque((Boolean) o); break; case drawOutline: // g.drawString((String)o1, (Integer)o2, (Integer)o3) ;break; { FontRenderContext frc = g.getFontRenderContext(); TextLayout tl = new TextLayout((String) o1, g.getFont(), frc); Shape s1 = tl.getOutline(null); AffineTransform af = g.getTransform(); g.translate((Integer) o2, (Integer) o3); g.draw(s1); g.setTransform(af); } ; break; default: System.out.println("Unknown image operation " + s); } }
private void shadeRect(Graphics2D g2, int r, int g, int b, int a) { g2.setPaint(new Color(r, g, b, a)); g2.fillRect(rect.x + 1, rect.y + 1, rect.width - 1, rect.height - 1); }
@Override public void render(Graphics2D g, VisualItem item) { if (item.isVisible()) { item.setShape(Constants.SHAPE_RECTANGLE); RectangularShape shape = (RectangularShape) getShape(item); if (shape != null) { shape .getBounds2D() .setRect( (double) item.get(VisualItem.X), (double) item.get(VisualItem.Y), item.getSize(), item.getSize()); // draw basic glyph Color strokeColor = ColorLib.getColor(item.getStrokeColor()); Color fillColor = ColorLib.getColor(item.getFillColor()); // int size = (int)item.getSize(); int x = (int) item.getX() + bufferPx; int y = (int) item.getY() + bufferPx; int w = (int) item.getDouble(WIDTH) - 2 * bufferPx; int h = (int) item.getDouble(HEIGHT) - 2 * bufferPx; g.setPaint(fillColor); g.fillRect(x, y, w, h); // draw string on-top of glyph, filling the glyph's area // String s = "doc=" + item.getString(NODE_NAME) + "\n"; String s = ""; // set text: full document if no search term, else excerpts containing the search term String queryStr = searchQ.getSearchSet().getQuery(); String focusText = item.getString(DocumentGridTable.NODE_FOCUS_TEXT); if (queryStr != null && !queryStr.isEmpty() && focusText != null && !focusText.equals("null") && !focusText.equals("")) { // if search query and terms present in document, use term-containing spans s += focusText; } else if (queryStr != null && !queryStr.isEmpty() && focusText.equals(FOCUS_SENT_SPLITTER)) { // if search query but no terms present in document, use blank s += ""; } else if ((queryStr == null || queryStr.isEmpty()) && item.canGetInt(NODE_ID)) { // if no search query, build feature-oriented summary based on color attribute s = controller.getDocumentSummary(item.getInt(NODE_ID), colorAttrName); } // TODO : idea: set font size dynamically based on number of active nodes? based on size // of rect? int fontSize = 10; item.setFont(FontLib.getFont("Tahoma", Font.PLAIN, fontSize)); Font f = item.getFont(); // compute width, height for the given text // NOTE: this logic has been moved into drawStringMultiline // int[] textDims = getTextDims(g, f, s); // debug // System.out.println("debug: "+this.getClass().getName()+": // drawStringMultiline at x="+x1+", y="+y1+", w="+w+", h="+h); drawStringMultiline(g, f, s, x, y, w, h); } } }