/** * Draw a legend for this data set * * @param g Graphics context * @param w Data Window */ protected void draw_legend(Graphics g, Rectangle w) { Color c = g.getColor(); Markers m = null; if (legend_text == null) return; if (legend_text.isNull()) return; if (legend_ix == 0 && legend_iy == 0) { legend_ix = (int) (w.x + ((legend_dx - xmin) / xrange) * w.width); legend_iy = (int) (w.y + (1.0 - (legend_dy - ymin) / yrange) * w.height); } if (linestyle != DataSet.NOLINE) { if (linecolor != null) g.setColor(linecolor); g.drawLine(legend_ix, legend_iy, legend_ix + legend_length, legend_iy); } if (marker > 0) { m = g2d.getMarkers(); if (m != null) { if (markercolor != null) g.setColor(markercolor); else g.setColor(c); m.draw(g, marker, 1.0, legend_ix + legend_length / 2, legend_iy); } } legend_text.draw( g, legend_ix + legend_length + legend_text.charWidth(g, ' '), legend_iy + legend_text.getAscent(g) / 3); g.setColor(c); }
/** Draw the connector on the simulation's canvas */ public void draw(Graphics g) { Color tColor; tColor = g.getColor(); // save exisiting color g.setColor(color); g.drawLine((int) pointA.getX(), (int) pointA.getY(), (int) pointB.getX(), (int) pointB.getY()); g.setColor(tColor); // restore previous color }
public void draw(Graphics g) { Color oldColor = g.getColor(); g.setColor(color); if (filled) g.fillRect(cornerX, cornerY, width, height); else g.drawRect(cornerX, cornerY, width, height); g.setColor(oldColor); }
public void draw(Graphics graphics) { Color _oldColor = graphics.getColor(); graphics.setColor(hasExceptionHandlers(getActivity(), getData()) ? CI.RED : CI.LIGHTGREY); super.draw(graphics); graphics.setColor(_oldColor); }
/** * Draw the LineSelection at its current location. It is the responsibility of the * applet/application to draw the LineSelection at the appropriate times, e.g., inside the * component's update() and/or paint() method. This gives maximum flexibility for double * buffering, etc. * * @param g The Graphics context to use for drawing. */ public void draw(Graphics g) { if (!isVisible()) { return; } Color saveColor = g.getColor(); g.setColor(color); if (thickness > 1) { double ratio = ((double) thickness) / ((double) length()); double txdb = ratio * ((double) height) / 2.0; int tx = txdb > 0 ? ((int) Math.ceil(txdb)) : ((int) Math.floor(txdb)); double tydb = -ratio * ((double) width) / 2.0; int ty = tydb > 0 ? ((int) Math.ceil(tydb)) : ((int) Math.floor(tydb)); Point[] poly = new Point[4]; for (int i = 0; i < 4; i++) poly[i] = new Point(x, y); poly[0].translate(tx, ty); poly[1].translate(-tx, -ty); poly[2].translate(width, height); poly[2].translate(-tx, -ty); poly[3].translate(width, height); poly[3].translate(tx, ty); Polygon polygon = new Polygon(); for (int i = 0; i < 4; i++) polygon.addPoint(poly[i].x, poly[i].y); g.fillPolygon(polygon); } else g.drawLine(x, y, x + width, y + height); g.setColor(saveColor); } // end draw
@Override public void draw(Graphics graphicsInstance) { Color oldColor = graphicsInstance.getColor(); graphicsInstance.setColor(this.getShapeColor()); graphicsInstance.drawLine(getStartX(), getStartY(), getEndX(), getEndY()); graphicsInstance.setColor(oldColor); }
/** * Paint this window. This method should not generally be overridden by subclasses. This method * carefully stores the clip, translation, and color before calling into subclasses. The graphics * context should be translated such that it is in this window's coordinate space (0,0 is the top * left corner of this window). * * @param g The graphics object to use to paint this window. * @param refreshQ The custom queue which holds the set of refresh regions needing to be blitted * to the screen */ public void paint(Graphics g, CGraphicsQ refreshQ) { // We reset our dirty flag first. Any layers that become // dirty in the duration of this method will then cause it // to toggle back to true for the subsequent pass. // IMPL NOTE: when layers start to do complex animation, there will // likely need to be better atomic handling of the dirty state, // and layers becoming dirty and getting painted this.dirty = false; // Store the clip, translate, font, color cX = g.getClipX(); cY = g.getClipY(); cW = g.getClipWidth(); cH = g.getClipHeight(); tranX = g.getTranslateX(); tranY = g.getTranslateY(); font = g.getFont(); color = g.getColor(); // We set the basic clip to the size of this window g.setClip(bounds[X], bounds[Y], bounds[W], bounds[H]); synchronized (layers) { sweepAndMarkLayers(); copyAndCleanDirtyLayers(); } paintLayers(g, refreshQ); // We restore the original clip. The original font, color, etc. // have already been restored g.setClip(cX, cY, cW, cH); }
public void paintIcon(Component c, Graphics g, int x, int y) { boolean enabled = c.isEnabled(); // paint the icon Icon paintedIcon = enabled ? icon : disabledIcon; if (paintedIcon != null) paintedIcon.paintIcon(c, g, x, y); // backup current color Color oldColor = g.getColor(); int insetx = 4; if (c instanceof JComponent) { Insets borderinset = ((JComponent) c).getBorder().getBorderInsets(c); insetx = borderinset.left; } if (paintedIcon != null) { g.translate(paintedIcon.getIconWidth() + X_GAP + insetx, 0); } arrow.paintIcon(c, g, x, y); if (paintedIcon != null) { g.translate(-paintedIcon.getIconWidth() - X_GAP - insetx, 0); } // restore previous color g.setColor(oldColor); }
@Override public void paint(Graphics g) { final Color color = g.getColor(); g.setColor(myColor); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(color); }
/** * Metoda wyswietlajaca pasek postepu nad przyciskami * * @param g Referencja do obiektu klasy Graphics, ktory pozwala na narysowanie pasku postepu * @param current Aktualny czas trwania piosenki, 0 <= progress <= max * @param max Calkowity czas trwania piosenki */ public void showProgressBar(Graphics g, int current, int max) { int color = g.getColor(); // przechowanie uzywanego koloru int progressBarWidth = screenWidth - 25; // szerokosc paska postepu int progress = (progressBarWidth * current) / max; if (current == -1) // jesli timer jest wylaczony progress = 0; g.setColor(110, 110, 110); // narysowanie szarej obwodki g.drawRect(10, screenHeight - 29 + buttonsLocation, progressBarWidth + 3, 17); g.setColor(90, 90, 90); // narysowanie ciemnej obwodki g.drawRect(11, screenHeight - 28 + buttonsLocation, progressBarWidth + 1, 15); g.setColor(BACKGROUND_COLOR); g.fillRect(12, screenHeight - 27 + buttonsLocation, progressBarWidth, 14); g.setColor(230, 230, 230); g.fillRect(12, screenHeight - 27 + buttonsLocation, progress, 14); g.setColor(70, 70, 70); if (this.displayedScreen == MainCanvas.PLAYER_SCREEN) g.drawString( bluetoothPlayer.getCurrentTimeString(), screenWidth / 2 - 17, screenHeight - 26 + buttonsLocation, Graphics.TOP | Graphics.LEFT); g.setColor(color); }
/** * Draw the vectors at the data points. If this data has been attached to an Axis then scale the * data based on the axis maximum/minimum otherwise scale using the data's maximum/minimum * * @param g Graphics state * @param bounds The data window to draw into */ public void draw_data(Graphics g, Rectangle bounds) { Color c; if (xaxis != null) { xmax = xaxis.maximum; xmin = xaxis.minimum; } if (yaxis != null) { ymax = yaxis.maximum; ymin = yaxis.minimum; } xrange = xmax - xmin; yrange = ymax - ymin; /* ** draw the legend before we clip the data window */ draw_legend(g, bounds); /* ** Clip the data window */ if (clipping) g.clipRect(bounds.x, bounds.y, bounds.width, bounds.height); c = g.getColor(); if (linecolor != null) g.setColor(linecolor); else g.setColor(c); drawVectors(g, bounds); g.setColor(c); }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (comp.hasFocus() || focusLostTemporarily) { Color color = g.getColor(); g.setColor(focusColor); BasicGraphicsUtils.drawDashedRect(g, x, y, width, height); g.setColor(color); } }
/* * Draws a frame around the data area. */ protected void drawFrame(Graphics g, int x, int y, int width, int height) { Color c = g.getColor(); if (framecolor != null) g.setColor(framecolor); g.drawRect(x, y, width, height); g.setColor(c); }
/** draws the bullet */ public void draw(Graphics g, Color color) { Color bak = g.getColor(); Graphics2D g2 = (Graphics2D) g; g.setColor(color); int ix = (int) x; int iy = (int) y; g2.draw(this); g.setColor(bak); }
public void paintIcon(Component c, Graphics g, int x, int y) { Color oldColor = g.getColor(); boolean enabled = c.isEnabled(); boolean pressed = false; if (c instanceof JButton) { pressed = ((JButton) c).getModel().isPressed(); } int i = 0; int j = 0; int w = Math.min(width, c.getWidth()); int h = c.getHeight(); if (h < 5 || w < 5) { // not enough space for the arrow g.setColor(oldColor); return; } int size = Math.min(h / 2, w / 2); size = Math.max(size, 2); int mid = size / 2; x = ((w - size) / 2); // center arrow y = (h - size) / 2; // center arrow if (pressed) { x++; y++; } g.translate(x, y); // move the x,y origin in the graphic if (enabled) g.setColor(UIManager.getColor("controlDkShadow")); // NOT // LOCALIZABLE else g.setColor(UIManager.getColor("controlShadow")); // NOT // LOCALIZABLE if (!enabled) { g.translate(1, 1); g.setColor(UIManager.getColor("controlLtHighlight")); // NOT // LOCALIZABLE for (i = size - 1; i >= 0; i--) { g.drawLine(mid - i, j, mid + i, j); j++; } g.translate(-1, -1); g.setColor(UIManager.getColor("controlShadow")); // NOT // LOCALIZABLE } j = 0; for (i = size - 1; i >= 0; i--) { g.drawLine(mid - i, j, mid + i, j); j++; } g.translate(-x, -y); g.setColor(oldColor); }
public void draw(Graphics g) { getDirection(); move(); Color c = g.getColor(); g.setColor(TANK_COLOR); g.fillOval(xpos, ypos, TANK_RADIUS, TANK_RADIUS); drawPT(g); g.setColor(c); }
/** * This paints the entire plot. It calls the draw methods of all the attached axis and data sets. * The order of drawing is - Axis first, data legends next, data last. * * @params g Graphics state. */ public void paint(Graphics g) { int i; Graphics lg = g.create(); Rectangle r = bounds(); /* The r.x and r.y returned from bounds is relative to the ** parents space so set them equal to zero. */ r.x = 0; r.y = 0; if (DefaultBackground == null) DefaultBackground = this.getBackground(); if (DataBackground == null) DataBackground = this.getBackground(); // System.out.println("Graph2D paint method called!"); if (!paintAll) return; r.x += borderLeft; r.y += borderTop; r.width -= borderLeft + borderRight; r.height -= borderBottom + borderTop; paintFirst(lg, r); if (!axis.isEmpty()) r = drawAxis(lg, r); else { if (clearAll) { Color c = g.getColor(); g.setColor(DataBackground); g.fillRect(r.x, r.y, r.width, r.height); g.setColor(c); } drawFrame(lg, r.x, r.y, r.width, r.height); } paintBeforeData(lg, r); if (!dataset.isEmpty()) { datarect.x = r.x; datarect.y = r.y; datarect.width = r.width; datarect.height = r.height; for (i = 0; i < dataset.size(); i++) { ((DataSet) dataset.elementAt(i)).draw_data(lg, r); } } paintLast(lg, r); lg.dispose(); }
public void draw(Graphics g) { getDirection(); move(); Color c = g.getColor(); Color tankColor = (isMe) ? MY_TANK_COLOR : ENENMY_TANK_COLOR; g.setColor(tankColor); g.fillOval(xpos, ypos, TANK_RADIUS, TANK_RADIUS); drawPT(g); g.setColor(c); }
/** * Metoda wyswietlajaca okreg obrazujacy postep wykrywania urzadzen * * @param g Referencja do obiektu klasy Graphics, ktory pozwala na narysowanie pasku postepu * @param progress Liczba z zakresu 0 - 359: zakres luku */ public void showInquiryProgress(Graphics g, int progress) { int c = g.getColor(); g.setColor(255, 255, 255); g.drawArc(screenWidth - 25, screenHeight - 57, 10, 16, 0, progress); g.setColor(c); bluetoothLogoSmallSprite.setPosition(screenWidth - 24, screenHeight - 56); bluetoothLogoSmallSprite.paint(g); }
private void paintBorder( Graphics g, EditorImpl editor, int startOffset, int endOffset, Color color, EffectType effectType) { Color savedColor = g.getColor(); g.setColor(color); paintBorder(g, editor, startOffset, endOffset, effectType); g.setColor(savedColor); }
public void paint(Graphics graphics, long time) { // Save the old color. Color oldColor = graphics.getColor(); // Set the new color. graphics.setColor(color.getColor(time)); // Paint the actual sprite. sprite.paint(graphics, time); // Restore the old color. graphics.setColor(oldColor); }
public void update(Graphics g) { if (offScreenImage == null) offScreenImage = this.createImage(GAME_WIDTH, GAME_HEIGHT); Graphics gOffScreenImage = offScreenImage.getGraphics(); Color c = gOffScreenImage.getColor(); gOffScreenImage.setColor(BACKGROUND_COLOR); gOffScreenImage.fillRect(0, 0, GAME_WIDTH, GAME_HEIGHT); gOffScreenImage.setColor(c); paint(gOffScreenImage); g.drawImage(offScreenImage, 0, 0, null); }
public void paintJaggedLine(Graphics g, Shape a) { int y = (int) (a.getBounds().getY() + a.getBounds().getHeight()); int x1 = (int) a.getBounds().getX(); int x2 = (int) (a.getBounds().getX() + a.getBounds().getWidth()); Color old = g.getColor(); g.setColor(Color.red); // g.drawLine(x1, y, x2, y); g.drawRect(x1, (int) a.getBounds().getY(), x2 - x1, (int) a.getBounds().getHeight()); // for (int i = x1; i <= x2; i += 6) { // g.drawArc(i + 3, y - 3, 3, 3, 0, 180); // g.drawArc(i + 6, y - 3, 3, 3, 180, 181); // } g.setColor(old); }
private void paintHorizontal(Graphics g) { // x and y coordinates to draw/write to int cx, cy; int barHeight = metrics.getHeight(); for (int i = 0; i < columns; i++) { // set the X coordinate for this bar and label and center it int widthOfItems = maxLabelWidth + 3 + (maxValue * scale) + 5 + metrics.stringWidth(Integer.toString(maxValue)); cx = Math.max((getSize().width - widthOfItems) / 2, 0); // set the Y coordinate for this bar and label cy = getSize().height - metrics.getDescent() - metrics.getHeight() - barSpacing - ((columns - i - 1) * (barSpacing + barHeight)); // draw the label g.setColor(Color.black); g.drawString(labels[i], cx, cy); cx += maxLabelWidth + 3; // draw the shadow g.fillRect(cx + 4, cy - barHeight + 4, (values[i] * scale), barHeight); // draw the bar g.setColor(colors[i]); if (styles[i] == STRIPED) { for (int k = 0; k <= values[i] * scale; k += 2) { g.drawLine(cx + k, cy - barHeight, cx + k, cy); } } else { // SOLID g.fillRect(cx, cy - barHeight, (values[i] * scale) + 1, barHeight + 1); } cx += (values[i] * scale) + 4; // draw the value at the end of the bar g.setColor(g.getColor().darker()); g.drawString(Integer.toString(values[i]), cx, cy); } }
private void drawBalance(Graphics g) // POST: Draws the balance of the current player { Font font; // Font used to draw balance String message; // Message for balance Color oldColor; // Sets for color int x1; // Upper-left x coordinate int y1; // Upper-left y coordinate int x2; // Bottom-right x coordinate int y2; // Bottom-right y coordinate int width; // Width of the dialogue box int height; // Height of the dialogue box int offset; // Offset so the dialogue box is positioned int balance; // Offset so the dialogue box is positioned User player; // User value for the player player = usersArray[0]; balance = player.getBalance(); oldColor = g.getColor(); x1 = ScaledPoint.scalerToX(0.72); y1 = ScaledPoint.scalerToY(0.81); x2 = ScaledPoint.scalerToX(0.88); y2 = ScaledPoint.scalerToY(0.86); width = x2 - x1; height = y2 - y1; message = "Balance:"; font = Drawing.getFont(message, width, height, FONTNAME, FONTSTYLE); offset = (width - getFontMetrics(font).stringWidth(message)) / 2; g.setColor(Color.WHITE); g.drawString(message, x1 + offset, y2); x1 = ScaledPoint.scalerToX(0.72); y1 = ScaledPoint.scalerToY(0.865); x2 = ScaledPoint.scalerToX(0.88); y2 = ScaledPoint.scalerToY(0.915); width = x2 - x1; height = y2 - y1; message = "$" + Integer.toString(balance); font = Drawing.getFont(message, width, height, FONTNAME, FONTSTYLE); offset = (width - getFontMetrics(font).stringWidth(message)) / 2; g.drawString(message, x1 + offset, y2); g.setColor(oldColor); }
/** * this method has to be overridden to paint the icon. The point itself lies at coordinates (0, 0) */ @Override public void paint(Graphics g) { Color prev = g.getColor(); if (this.individual.isMarked()) { this.fillColor = Color.RED; } else { this.fillColor = Color.LIGHT_GRAY; } g.setColor(fillColor); g.fillOval(-this.size, -this.size, 2 * this.size + 1, 2 * this.size + 1); if (this.borderColor != null) { g.setColor(borderColor); } g.drawOval(-this.size, -this.size, 2 * this.size, 2 * this.size); g.setColor(prev); }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (!isProperty) { Color oldColor = g.getColor(); g.setColor(c.getBackground()); g.fillRect(x, y, x + HOTSPOT_SIZE - 2, y + height); g.setColor(oldColor); } if (showToggle) { Icon drawIcon = (toggleState ? expandedIcon : collapsedIcon); drawIcon.paintIcon( c, g, x + indentWidth + (HOTSPOT_SIZE - 2 - drawIcon.getIconWidth()) / 2, y + (height - drawIcon.getIconHeight()) / 2); } }
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (myColor != null) { final Icon icon = getIcon(); final int width = icon.getIconWidth(); final int height = icon.getIconHeight(); final Color old = g.getColor(); g.setColor(myColor); g.fillRect(0, 0, width, height); g.setColor(old); } }
@Override public void paint(Graphics g) { Font f = g.getFont(); if (font != null) { g.setFont(font); } Color c = g.getColor(); g.setColor(getColor()); g.drawText(text, horizontalReference, verticalReference, rotation, coord); g.setColor(c); if (font != null) { g.setFont(f); } }
public void paintIcon(Component c, Graphics g, int x, int y) { if (color != null) { Color oldColor = g.getColor(); g.setColor(color); g.fillRect(x, y, getIconWidth(), insets.top); g.fillRect(x, y + getIconHeight() - insets.bottom, getIconWidth(), insets.bottom); g.fillRect(x, y + insets.top, insets.left, getIconHeight() - insets.top - insets.bottom); g.fillRect( x + getIconWidth() - insets.right, y + insets.top, insets.right, getIconHeight() - insets.top - insets.bottom); g.setColor(oldColor); } icon.paintIcon(c, g, x + insets.left, y + insets.top); }