List of usage examples for java.awt Graphics fillRect
public abstract void fillRect(int x, int y, int width, int height);
From source file:com.lfv.lanzius.server.WorkspaceView.java
@Override protected void paintComponent(Graphics g) { int w = getWidth(); int h = getHeight(); Document doc = server.getDocument(); Color storedCol = g.getColor(); Font storedFont = g.getFont(); // Fill workspace area g.setColor(getBackground());/*from www .j a va 2s .co m*/ g.fillRect(0, 0, w, h); // Should the cached version be updated? int updateDocumentVersion = server.getDocumentVersion(); boolean update = (documentVersion != updateDocumentVersion); // Check if we have cached the latest document version, otherwise cache the terminals if (update) { log.debug("Updating view to version " + updateDocumentVersion); terminalMap.clear(); groupList.clear(); if (doc != null) { synchronized (doc) { // Clear the visible attribute on all groups // except the started or paused ones Element egd = doc.getRootElement().getChild("GroupDefs"); Iterator iter = egd.getChildren().iterator(); while (iter.hasNext()) { Element eg = (Element) iter.next(); boolean isVisible = !DomTools.getAttributeString(eg, "state", "stopped", false) .equals("stopped"); eg.setAttribute("visible", String.valueOf(isVisible)); } // Gather information about terminals and cache it Element etd = doc.getRootElement().getChild("TerminalDefs"); iter = etd.getChildren().iterator(); while (iter.hasNext()) { Element et = (Element) iter.next(); int tid = DomTools.getAttributeInt(et, "id", 0, false); if (tid > 0) { // Create terminal and add it to list Terminal t = new Terminal(tid, DomTools.getAttributeInt(et, "x", 0, false), DomTools.getAttributeInt(et, "y", 0, false), DomTools.getChildText(et, "Name", "T/" + tid, false), DomTools.getAttributeBoolean(et, "online", false, false), DomTools.getAttributeBoolean(et, "selected", false, false)); terminalMap.put(tid, t); // Is the terminal monitored? t.isMonitored = DomTools.getAttributeBoolean(et, "monitored", false, false); // Examine the Player element under PlayerSetup t.groupColor = null; Element ep = DomTools.getElementFromSection(doc, "PlayerSetup", "terminalid", String.valueOf(tid)); // Has linked player for this terminal if (ep != null) { StringBuffer sb = new StringBuffer(); // Append player name sb.append(DomTools.getChildText(ep, "Name", "P/?", true)); sb.append(" ("); // Append role list boolean hasRoles = false; Element ers = ep.getChild("RoleSetup"); if (ers != null) { Iterator iterr = ers.getChildren().iterator(); while (iterr.hasNext()) { Element er = (Element) iterr.next(); String id = er.getAttributeValue("id"); er = DomTools.getElementFromSection(doc, "RoleDefs", "id", id); if (er != null) { sb.append(DomTools.getChildText(er, "Name", "R/" + id, false)); sb.append(", "); hasRoles = true; } } if (hasRoles) { // Trim last comma int len = sb.length(); sb.setLength(Math.max(len - 2, 0)); } sb.append(")"); } t.roles = sb.toString(); // Is the player relocated? t.isRelocated = DomTools.getAttributeBoolean(ep, "relocated", false, false); // Get group name and color Element eg = DomTools.getElementFromSection(doc, "GroupDefs", "id", DomTools.getAttributeString(ep, "groupid", "0", true)); t.groupColor = Color.lightGray; if (eg != null) { String sc = DomTools.getChildText(eg, "Color", null, false); if (sc != null) { try { t.groupColor = Color.decode(sc); } catch (NumberFormatException ex) { log.warn("Invalid color attribute on Group node, defaulting to grey"); } } //t.name += " "+DomTools.getChildText(eg, "Name", "G/"+eg.getAttributeValue("id"), false); t.groupName = DomTools.getChildText(eg, "Name", "G/" + eg.getAttributeValue("id"), false); // This group should now be visible eg.setAttribute("visible", "true"); } else log.warn("Invalid groupid attribute on Player node, defaulting to grey"); } } else log.error("Invalid id attribute on Terminal node, skipping"); } // Gather information about groups and cache it iter = egd.getChildren().iterator(); while (iter.hasNext()) { Element eg = (Element) iter.next(); if (DomTools.getAttributeBoolean(eg, "visible", false, false)) { int gid = DomTools.getAttributeInt(eg, "id", 0, true); if (gid > 0) { Group grp = new Group(gid, DomTools.getChildText(eg, "Name", "G/" + gid, false), DomTools.getAttributeBoolean(eg, "selected", false, false)); groupList.add(grp); // group color String sc = DomTools.getChildText(eg, "Color", null, false); if (sc != null) { try { grp.color = Color.decode(sc); } catch (NumberFormatException ex) { log.warn("Invalid color attribute on Group node, defaulting to grey"); } } // state color grp.stateColor = Color.red; String state = DomTools.getAttributeString(eg, "state", "stopped", false); if (state.equals("started")) grp.stateColor = Color.green; else if (state.equals("paused")) grp.stateColor = Color.orange; } } } } } } if (doc == null) { g.setColor(Color.black); String text = "No configuration loaded. Select 'Load configuration...' from the file menu."; g.drawString(text, (w - SwingUtilities.computeStringWidth(g.getFontMetrics(), text)) / 2, h * 5 / 12); } else { g.setFont(new Font("Dialog", Font.BOLD, 13)); Iterator<Terminal> itert = terminalMap.values().iterator(); while (itert.hasNext()) { Terminal t = itert.next(); // Draw box int b = t.isSelected ? SERVERVIEW_SELECTION_BORDER : 1; g.setColor(Color.black); g.fillRect(t.x + SERVERVIEW_SELECTION_BORDER - b, t.y + SERVERVIEW_SELECTION_BORDER - b, SERVERVIEW_TERMINAL_WIDTH + 2 * b, SERVERVIEW_TERMINAL_HEIGHT + 2 * b); g.setColor(t.groupColor == null ? Color.white : t.groupColor); g.fillRect(t.x + SERVERVIEW_SELECTION_BORDER, t.y + SERVERVIEW_SELECTION_BORDER, SERVERVIEW_TERMINAL_WIDTH, SERVERVIEW_TERMINAL_HEIGHT); // Inner areas Rectangle r = new Rectangle(t.x + SERVERVIEW_SELECTION_BORDER + SERVERVIEW_TERMINAL_BORDER, t.y + SERVERVIEW_SELECTION_BORDER + SERVERVIEW_TERMINAL_BORDER, SERVERVIEW_TERMINAL_WIDTH - 2 * SERVERVIEW_TERMINAL_BORDER, g.getFontMetrics().getHeight() + 4); g.setColor(Color.white); g.fillRect(r.x, r.y, r.width, r.height); g.fillRect(r.x, r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 2, r.width, SERVERVIEW_TERMINAL_HEIGHT - 3 * SERVERVIEW_TERMINAL_BORDER - r.height - 2); g.setColor(Color.black); g.drawRect(r.x, r.y, r.width, r.height); g.drawRect(r.x, r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 2, r.width, SERVERVIEW_TERMINAL_HEIGHT - 3 * SERVERVIEW_TERMINAL_BORDER - r.height - 2); // Name of terminal and group if (server.isaClient(t.tid)) { g.drawImage(indicatorIsa.getImage(), r.x + r.width - 20, r.y + SERVERVIEW_TERMINAL_HEIGHT - 26, null); } g.drawString(t.name + " " + t.groupName, r.x + 4, r.y + r.height - 4); double px = r.x + 4; double py = r.y + r.height + SERVERVIEW_TERMINAL_BORDER + 5; // Draw monitored indicator if (t.isMonitored) { g.drawImage(indicatorMonitored.getImage(), r.x + r.width - 9, r.y + 3, null); } // Draw relocated indicator if (t.isRelocated) { g.drawImage(indicatorRelocated.getImage(), r.x + r.width - 9, r.y + 13, null); } // Draw online indicator r.setBounds(r.x, r.y + r.height, r.width, 3); g.setColor(t.isOnline ? Color.green : Color.red); g.fillRect(r.x, r.y, r.width, r.height); g.setColor(Color.black); g.drawRect(r.x, r.y, r.width, r.height); // Roles if (t.roles.length() > 0) { LineBreakMeasurer lbm = new LineBreakMeasurer(new AttributedString(t.roles).getIterator(), new FontRenderContext(null, false, true)); TextLayout layout; while ((layout = lbm .nextLayout(SERVERVIEW_TERMINAL_WIDTH - 2 * SERVERVIEW_TERMINAL_BORDER)) != null) { if (py < t.y + SERVERVIEW_TERMINAL_HEIGHT) { py += layout.getAscent(); layout.draw((Graphics2D) g, (int) px, (int) py); py += layout.getDescent() + layout.getLeading(); } } } } // Draw group indicators int nbrGroupsInRow = w / (2 * Constants.SERVERVIEW_SELECTION_BORDER + 2 + Constants.SERVERVIEW_GROUP_WIDTH); if (nbrGroupsInRow < 1) nbrGroupsInRow = 1; int nbrGroupRows = (groupList.size() + nbrGroupsInRow - 1) / nbrGroupsInRow; int innerWidth = Constants.SERVERVIEW_GROUP_WIDTH; int innerHeight = g.getFontMetrics().getHeight() + 5; int outerWidth = innerWidth + 2 * Constants.SERVERVIEW_SELECTION_BORDER + 2; int outerHeight = innerHeight + 2 * Constants.SERVERVIEW_SELECTION_BORDER + 2; int x = 0; int y = h - outerHeight * nbrGroupRows; g.setColor(Color.white); g.fillRect(0, y, w, h - y); g.setColor(Color.black); g.drawLine(0, y - 1, w - 1, y - 1); Iterator<Group> iterg = groupList.iterator(); while (iterg.hasNext()) { Group grp = iterg.next(); // Group box grp.boundingRect.setBounds(x, y, outerWidth, outerHeight); int b = grp.isSelected ? Constants.SERVERVIEW_SELECTION_BORDER : 1; g.setColor(Color.black); g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER - b + 1, y + Constants.SERVERVIEW_SELECTION_BORDER - b + 1, innerWidth + 2 * b, innerHeight + 2 * b); g.setColor(grp.color); g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER + 1, y + Constants.SERVERVIEW_SELECTION_BORDER + 1, innerWidth, innerHeight); g.setColor(Color.black); g.drawString(grp.name, x + Constants.SERVERVIEW_SELECTION_BORDER + 4, y + Constants.SERVERVIEW_SELECTION_BORDER + innerHeight - 4 + 1); // Draw started indicator g.setColor(grp.stateColor); g.fillRect(x + Constants.SERVERVIEW_SELECTION_BORDER + 1, y + Constants.SERVERVIEW_SELECTION_BORDER + 1, innerWidth, 2); g.setColor(Color.black); g.drawLine(x + Constants.SERVERVIEW_SELECTION_BORDER + 1, y + Constants.SERVERVIEW_SELECTION_BORDER + 3, x + Constants.SERVERVIEW_SELECTION_BORDER + 1 + innerWidth, y + Constants.SERVERVIEW_SELECTION_BORDER + 3); x += outerWidth; if ((x + outerWidth) > w) { x = 0; y += outerHeight; } } } // Store cached version documentVersion = updateDocumentVersion; g.setColor(storedCol); g.setFont(storedFont); }
From source file:org.openlegacy.terminal.render.DefaultTerminalSnapshotImageRenderer.java
private void markBackgroundAndInputFields(TerminalSnapshot terminalSnapshot, Graphics graphics) { int endX;//from w w w. ja va 2 s. co m List<TerminalField> fields = terminalSnapshot.getFields(); setDefaultColor(graphics); for (TerminalField terminalField : fields) { TerminalPosition position = terminalField.getPosition(); // -1 - pixels is 0 based , column is 1 based int startX = toWidth(position.getColumn() - 1 + leftColumnsOffset); int startY = toHeight(position.getRow()); endX = toWidth(terminalField.getEndPosition().getColumn() + leftColumnsOffset); if (terminalField.isEditable()) { graphics.drawLine(startX, startY, endX, startY); } int rowHeight = toHeight(1); if (terminalField.getBackColor() != org.openlegacy.terminal.Color.BLACK) { graphics.setColor(SnapshotUtils.convertColor(terminalField.getBackColor())); // graphics.fillRect(startX, toHeight(position.getRow() - 1) + topPixelsOffset, toWidth(terminalField.getLength()), rowHeight); } } if (drawFieldSeparators) { List<TerminalPosition> fieldSeperators = terminalSnapshot.getFieldSeperators(); graphics.setColor(imageDefaultTextColor); for (TerminalPosition terminalPosition : fieldSeperators) { graphics.drawString("^", toWidth(terminalPosition.getColumn() - 1 + leftColumnsOffset), toHeight(terminalPosition.getRow())); } } }
From source file:ExtendedTableCellRenderer.java
public void paint(Graphics g) { super.paint(g); if (underlined) { Insets i = getInsets();//from w w w . j av a2s .c om FontMetrics fm = g.getFontMetrics(); Rectangle textRect = new Rectangle(); Rectangle viewRect = new Rectangle(i.left, i.top, getWidth() - (i.right + i.left), getHeight() - (i.bottom + i.top)); SwingUtilities.layoutCompoundLabel(this, fm, getText(), getIcon(), getVerticalAlignment(), getHorizontalAlignment(), getVerticalTextPosition(), getHorizontalTextPosition(), viewRect, new Rectangle(), textRect, getText() == null ? 0 : ((Integer) UIManager.get("Button.textIconGap")).intValue()); int offset = 2; if (UIManager.getLookAndFeel().isNativeLookAndFeel() && System.getProperty("os.name").startsWith("Windows")) { offset = 1; } g.fillRect(textRect.x + ((Integer) UIManager.get("Button.textShiftOffset")).intValue(), textRect.y + fm.getAscent() + ((Integer) UIManager.get("Button.textShiftOffset")).intValue() + offset, textRect.width, 1); } }
From source file:net.sf.jasperreports.swing.JRViewerPanel.java
protected void drawPageError(Graphics grx) { PrintPageFormat pageFormat = viewerContext.getPageFormat(); grx.setColor(Color.white);//from ww w .java 2 s.c o m grx.fillRect(0, 0, pageFormat.getPageWidth() + 1, pageFormat.getPageHeight() + 1); }
From source file:org.processmining.analysis.performance.advanceddottedchartanalysis.ui.DottedChartPanel.java
/** * paints this log item panel and all contained log items as specified. * //from w ww. ja v a 2s . com * @param g * the graphics object used for painting */ public void paintComponent(Graphics grx) { Graphics gr = grx.create(); if (this.isOpaque()) { gr.setColor(colorBg); gr.fillRect(0, 0, getWidth(), getHeight()); } if ((int) gr.getClipBounds().getMinX() < coUtil.getClipL() || (int) gr.getClipBounds().getMaxX() > coUtil.getClipR() || (int) gr.getClipBounds().getMinY() < coUtil.getClipU() || (int) gr.getClipBounds().getMaxY() > coUtil.getClipB()) { modelBuffer = null; } if (modelBuffer == null) { this.setToolTipText(null); if (this.getWidth() <= SCREENLENGTH) { coUtil.setClipL(0); coUtil.setClipR(this.getWidth()); } else { int x1 = (SCREENLENGTH - gr.getClipBounds().width) / 2; int x2 = (int) gr.getClipBounds().getMinX() - x1; if (x2 <= 0) { coUtil.setClipL(0); coUtil.setClipR(SCREENLENGTH); } else if (x2 + SCREENLENGTH >= this.getWidth()) { coUtil.setClipR(this.getWidth()); coUtil.setClipL(this.getWidth() - SCREENLENGTH); } else { coUtil.setClipL(x2); coUtil.setClipR(x2 + SCREENLENGTH); } } if (this.getHeight() <= SCREENLENGTH) { coUtil.setClipU(0); coUtil.setClipB(this.getHeight()); } else { int y1 = (SCREENLENGTH - gr.getClipBounds().height) / 2; int y2 = (int) gr.getClipBounds().getMinY() - y1; if (y2 <= 0) { coUtil.setClipU(0); coUtil.setClipB(SCREENLENGTH); } else if (y2 + SCREENLENGTH >= this.getHeight()) { coUtil.setClipU(this.getHeight() - SCREENLENGTH); coUtil.setClipB(this.getHeight()); } else { coUtil.setClipU(y2); coUtil.setClipB(y2 + SCREENLENGTH); } } coUtil.updateMilli2pixelsRatio(getWidth(), BORDER); if (dcop.isSizeCheckBoxSelected()) { drawModelBuffer(getWidth(), getHeight(), true); } else { drawModelBuffer_NO_SIZE(getWidth(), getHeight(), true); } } grx.drawImage(modelBuffer, coUtil.getClipL(), coUtil.getClipU(), this); // to do box for zoom if (p1 != null && p2 != null) { int x1 = Math.min(p1.x, p2.x); int y1 = Math.min(p1.y, p2.y); int width = Math.abs(p1.x - p2.x); int height = Math.abs(p1.y - p2.y); grx.drawRect(x1, y1, width, height); } }
From source file:org.rdv.ui.TimeSlider.java
/** * Paint the components. Also paint the slider and the markers. *//* www. j av a2s .c om*/ protected void paintComponent(Graphics g) { super.paintComponent(g); Insets insets = getInsets(); g.setColor(Color.lightGray); g.fillRect(insets.left + 6, insets.top + 4, getWidth() - insets.left - 12 - insets.right, 3); if (isEnabled()) { g.setColor(Color.gray); int startX = getXFromTime(start); int endX = getXFromTime(end); g.fillRect(startX, insets.top + 4, endX - startX, 3); } for (EventMarker marker : markers) { double markerTime = Double.parseDouble(marker.getProperty("timestamp")); if (markerTime >= minimum && markerTime <= maximum) { int x = getXFromTime(markerTime); if (x == -1) { continue; } Image markerImage; String markerType = marker.getProperty("type"); if (markerType.compareToIgnoreCase("annotation") == 0) { markerImage = annotationMarkerImage; } else if (markerType.compareToIgnoreCase("start") == 0) { markerImage = startMarkerImage; } else if (markerType.compareToIgnoreCase("stop") == 0) { markerImage = stopMarkerImage; } else { markerImage = defaultMarkerImage; } g.drawImage(markerImage, x - 1, insets.top, null); } } }
From source file:de.tor.tribes.ui.views.DSWorkbenchReportFrame.java
@Override public void actionPerformed(ActionEvent e) { ReportTableTab activeTab = getActiveTab(); if (e.getActionCommand() != null && activeTab != null) { if (e.getActionCommand().equals("Copy")) { activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("BBCopy")) { activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.CLIPBOARD_BB); } else if (e.getActionCommand().equals("Cut")) { activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("Paste")) { activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD); } else if (e.getActionCommand().equals("Delete")) { activeTab.deleteSelection(true); } else if (e.getActionCommand().equals("Find")) { BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT); Graphics g = back.getGraphics(); g.setColor(new Color(120, 120, 120, 120)); g.fillRect(0, 0, back.getWidth(), back.getHeight()); g.setColor(new Color(120, 120, 120)); g.drawLine(0, 0, 3, 3);//from ww w.j a v a 2 s . c om g.dispose(); TexturePaint paint = new TexturePaint(back, new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight())); jxSearchPane.setBackgroundPainter(new MattePainter(paint)); DefaultListModel model = new DefaultListModel(); for (int i = 0; i < activeTab.getReportTable().getColumnCount(); i++) { TableColumnExt col = activeTab.getReportTable().getColumnExt(i); if (col.isVisible()) { if (!col.getTitle().equals("Status") && !col.getTitle().equals("Typ") && !col.getTitle().equals("Sonstiges")) { model.addElement(col.getTitle()); } } } jXColumnList.setModel(model); jXColumnList.setSelectedIndex(0); jxSearchPane.setVisible(true); } } }
From source file:ubic.gemma.web.controller.expression.experiment.ExpressionExperimentQCController.java
/** * Write a blank image so user doesn't see the broken icon. *//*from w w w. j a v a 2 s .c o m*/ private void writePlaceholderImage(OutputStream os) throws IOException { int placeholderSize = (int) (ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX * 0.75); BufferedImage buffer = new BufferedImage(placeholderSize, placeholderSize, BufferedImage.TYPE_INT_RGB); Graphics g = buffer.createGraphics(); g.setColor(Color.lightGray); g.fillRect(0, 0, placeholderSize, placeholderSize); g.setColor(Color.black); g.drawString("Not available", placeholderSize / 4, placeholderSize / 4); ImageIO.write(buffer, "png", os); }
From source file:ubic.gemma.web.controller.expression.experiment.ExpressionExperimentQCController.java
/** * Write a blank thumbnail image so user doesn't see the broken icon. *///w w w . ja va 2 s .c o m private void writePlaceholderThumbnailImage(OutputStream os, int placeholderSize) throws IOException { // Make the image a bit bigger to account for the empty space around the generated image. // If we can find a way to remove this empty space, we don't need to make the chart bigger. BufferedImage buffer = new BufferedImage(placeholderSize + 16, placeholderSize + 9, BufferedImage.TYPE_INT_RGB); Graphics g = buffer.createGraphics(); g.setColor(Color.white); g.fillRect(0, 0, placeholderSize + 16, placeholderSize + 9); g.setColor(Color.gray); g.drawLine(8, placeholderSize + 5, placeholderSize + 8, placeholderSize + 5); // x-axis g.drawLine(8, 5, 8, placeholderSize + 5); // y-axis g.setColor(Color.black); Font font = g.getFont(); g.setFont(new Font(font.getName(), font.getStyle(), 8)); g.drawString("N/A", 9, placeholderSize); ImageIO.write(buffer, "png", os); }
From source file:edu.umn.cs.spatialHadoop.core.OGCJTSShape.java
/** * Draw the given JTS Geometry to the graphics using specific scales in x and y * @param g Graphics to draw to//from w w w.j a v a 2s .co m * @param geom The geometry to draw * @param xscale The scale of the x-axis in terms in pixels/units * @param yscale The scale of the y-axis in terms of pixels/units * @param fill Whether to fill the shape or just draw an outline */ public static void drawJTSGeom(Graphics g, Geometry geom, double xscale, double yscale, boolean fill) { if (geom instanceof GeometryCollection) { GeometryCollection geom_coll = (GeometryCollection) geom; for (int i = 0; i < geom_coll.getNumGeometries(); i++) { Geometry sub_geom = geom_coll.getGeometryN(i); // Recursive call to draw each geometry drawJTSGeom(g, sub_geom, xscale, yscale, fill); } } else if (geom instanceof com.vividsolutions.jts.geom.Polygon) { com.vividsolutions.jts.geom.Polygon poly = (com.vividsolutions.jts.geom.Polygon) geom; for (int i = 0; i < poly.getNumInteriorRing(); i++) { LineString ring = poly.getInteriorRingN(i); drawJTSGeom(g, ring, xscale, yscale, fill); } drawJTSGeom(g, poly.getExteriorRing(), xscale, yscale, fill); } else if (geom instanceof LineString) { LineString line = (LineString) geom; double geom_alpha = line.getLength() * (xscale + yscale) / 2.0; int color_alpha = geom_alpha > 1.0 ? 255 : (int) Math.round(geom_alpha * 255); if (color_alpha == 0) return; int[] xpoints = new int[line.getNumPoints()]; int[] ypoints = new int[line.getNumPoints()]; int n = 0; for (int i = 0; i < xpoints.length; i++) { double px = line.getPointN(i).getX(); double py = line.getPointN(i).getY(); // Transform a point in the polygon to image coordinates xpoints[n] = (int) Math.round(px * xscale); ypoints[n] = (int) Math.round(py * yscale); // Include this point only if first point or different than previous point if (n == 0 || xpoints[n] != xpoints[n - 1] || ypoints[n] != ypoints[n - 1]) n++; } // Draw the polygon //graphics.setColor(new Color((shape_color.getRGB() & 0x00FFFFFF) | (color_alpha << 24), true)); if (n == 1) g.fillRect(xpoints[0], ypoints[0], 1, 1); else if (!fill) g.drawPolyline(xpoints, ypoints, n); else g.fillPolygon(xpoints, ypoints, n); } }