Java Code Examples for org.eclipse.draw2d.Graphics#drawLine()
The following examples show how to use
org.eclipse.draw2d.Graphics#drawLine() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlotArea.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void paintClientArea(final Graphics graphics) { super.paintClientArea(graphics); if (showBorder) { graphics.setLineWidth(2); graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y); graphics.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height); } // Show the start/end cursor or the 'rubberband' of a zoom operation? if (armed && end != null && start != null) { switch (zoomType) { case RUBBERBAND_ZOOM: case DYNAMIC_ZOOM: case HORIZONTAL_ZOOM: case VERTICAL_ZOOM: graphics.setLineStyle(SWTConstants.LINE_DOT); graphics.setLineWidth(1); graphics.setForegroundColor(revertBackColor); graphics.drawRectangle(start.x, start.y, end.x - start.x, end.y - start.y); break; default: break; } } }
Example 2
Source File: StreamFigure.java From scava with Eclipse Public License 2.0 | 6 votes |
protected void outlineShape(Graphics graphics) { graphics.drawOval(getOptimizedBounds().x + getOptimizedBounds().width * 4 / 5, getOptimizedBounds().y, getOptimizedBounds().width / 5, getOptimizedBounds().height); // graphics.drawArc(getOptimizedBounds().x, getOptimizedBounds().y, getOptimizedBounds().width / 5, getOptimizedBounds().height, 90, 180); // graphics.drawLine(getOptimizedBounds().x + getOptimizedBounds().width * 9 / 10, getOptimizedBounds().y, getOptimizedBounds().x + getOptimizedBounds().width * 1 / 10, getOptimizedBounds().y); graphics.drawLine(getOptimizedBounds().x + getOptimizedBounds().width * 1 / 10, getOptimizedBounds().y + getOptimizedBounds().height, getOptimizedBounds().x + getOptimizedBounds().width * 9 / 10, getOptimizedBounds().y + getOptimizedBounds().height); }
Example 3
Source File: NoteFigure.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void outlineShape(Graphics graphics) { Rectangle r = getBounds(); int x = r.x + getLineWidth() / 2; int y = r.y + getLineWidth() / 2; int w = r.width - Math.max(1, getLineWidth()); int h = r.height - Math.max(1, getLineWidth()); Rectangle bounds = new Rectangle(x, y, w, h); Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH); Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0); Point topRight3 = bounds.getTopRight().translate(-RETURN_WIDTH, RETURN_WIDTH); graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft()); graphics.drawLine(bounds.getBottomLeft(), bounds.getBottomRight()); graphics.drawLine(bounds.getBottomRight(), topRight1); graphics.drawLine(topRight1, topRight2); graphics.drawLine(topRight2, bounds.getTopLeft()); graphics.drawLine(topRight2, topRight3); graphics.drawLine(topRight3, topRight1); }
Example 4
Source File: CrossAnnotation.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void paintFigure(Graphics graphics) { if (trace != null && currentSnappedSample == null && !pointerDragged) updateToDefaultPosition(); if (Preferences.useAdvancedGraphics()) graphics.setAntialias(SWT.ON); graphics.setForegroundColor(getForegroundColor()); xValue = currentSnappedSample.getXValue(); yValue = currentSnappedSample.getYValue(); int x = xAxis.getValuePosition(xValue, false); int y = yAxis.getValuePosition(yValue, false); Point p = new Point(); p.setLocation(y, x); graphics.drawLine(x - CROSS_SIZE, y - CROSS_SIZE, x + CROSS_SIZE, y + CROSS_SIZE); graphics.drawLine(x - CROSS_SIZE, y + CROSS_SIZE, x + CROSS_SIZE, y - CROSS_SIZE); graphics.drawLine(x, y + CROSS_SIZE, x, y - CROSS_SIZE); graphics.drawLine(x - CROSS_SIZE, y, x + CROSS_SIZE, y); }
Example 5
Source File: ShallowHistoryFigure.java From statecharts with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.draw2d.Ellipse#outlineShape(org.eclipse.draw2d.Graphics) */ @Override protected void outlineShape(Graphics graphics) { graphics.pushState(); graphics.setForegroundColor(getBackgroundColor()); super.outlineShape(graphics); // draw the 'H' letter graphics.setForegroundColor(getForegroundColor()); graphics.setBackgroundColor(getBackgroundColor()); graphics.drawLine( bounds.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), (int) (-bounds.height * HEIGHT_RATIO)), bounds .getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), (int) (bounds.height * HEIGHT_RATIO))); graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * WIDTH_RATIO), (int) (-bounds.height * HEIGHT_RATIO)), bounds.getCenter().getTranslated((int) (bounds.width * WIDTH_RATIO), (int) (bounds.height * HEIGHT_RATIO))); graphics.drawLine(bounds.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), 0), bounds.getCenter() .getTranslated((int) (bounds.width * WIDTH_RATIO), 0)); graphics.popState(); }
Example 6
Source File: ProcessFigure.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void paintTable(Graphics graphics) { graphics.setForegroundColor(LINE_COLOR); int margin = 5; int width = getSize().width; int height = getSize().height; int x = getLocation().x; int y = getLocation().y; graphics.drawLine(new Point(x + margin, y + MINIMUM_HEIGHT + TEXT_HEIGHT + MARGIN_HEIGHT), new Point(x + width - margin, y + MINIMUM_HEIGHT + TEXT_HEIGHT + MARGIN_HEIGHT)); if (height - margin > MINIMUM_HEIGHT + margin) graphics.drawLine(new Point(x + width / 2, y + MINIMUM_HEIGHT + margin), new Point(x + width / 2, y + height - margin)); graphics.setForegroundColor(TEXT_COLOR); graphics.drawText(M.Inputs, new Point(x + width / 6, y + MINIMUM_HEIGHT + MARGIN_HEIGHT)); graphics.drawText(M.Outputs, new Point(x + 2 * width / 3, y + MINIMUM_HEIGHT + MARGIN_HEIGHT)); graphics.setForegroundColor(ColorConstants.black); }
Example 7
Source File: NoteFigure.java From ermasterr with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void outlineShape(final Graphics graphics) { final Rectangle r = getBounds(); final int x = r.x + getLineWidth() / 2; final int y = r.y + getLineWidth() / 2; final int w = r.width - Math.max(1, getLineWidth()); final int h = r.height - Math.max(1, getLineWidth()); final Rectangle bounds = new Rectangle(x, y, w, h); final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH); final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0); final Point topRight3 = bounds.getTopRight().translate(-RETURN_WIDTH, RETURN_WIDTH); graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft()); graphics.drawLine(bounds.getBottomLeft(), bounds.getBottomRight()); graphics.drawLine(bounds.getBottomRight(), topRight1); graphics.drawLine(topRight1, topRight2); graphics.drawLine(topRight2, bounds.getTopLeft()); graphics.drawLine(topRight2, topRight3); graphics.drawLine(topRight3, topRight1); }
Example 8
Source File: MultipleGuideHandle.java From birt with Eclipse Public License 1.0 | 6 votes |
protected void paintFigure( Graphics graphics ) { Rectangle rect = getBounds( ); graphics.setLineWidth( 2 ); graphics.drawRectangle( rect ); graphics.drawLine( rect.x, rect.y - 1, rect.x + rect.width, rect.y - 1 ); graphics.drawLine( rect.x, rect.y, rect.x, rect.y + rect.height ); graphics.setLineWidth( 3 ); graphics.drawLine( rect.x + rect.width, rect.y, rect.x + rect.width, rect.y + rect.height ); graphics.drawLine( rect.x, rect.y + rect.height, rect.x + rect.width, rect.y + rect.height ); }
Example 9
Source File: DeepHistoryFigure.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override protected void outlineShape(Graphics graphics) { graphics.pushState(); //Outline with foreground graphics.setForegroundColor(getBackgroundColor()); super.outlineShape(graphics); // draw the 'H' letter graphics.setForegroundColor(getForegroundColor()); graphics.setBackgroundColor(getBackgroundColor()); graphics.drawLine( bounds.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), (int) (-bounds.height * HEIGHT_RATIO)), bounds .getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), (int) (bounds.height * HEIGHT_RATIO))); graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * OFFSET), (int) (-bounds.height * HEIGHT_RATIO)), bounds.getCenter().getTranslated((int) (bounds.width * OFFSET), (int) (bounds.height * HEIGHT_RATIO))); graphics.drawLine(bounds.getCenter().getTranslated((int) (-bounds.width * WIDTH_RATIO), 0), bounds.getCenter() .getTranslated((int) (bounds.width * OFFSET), 0)); // draw the '*' character graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * WIDTH_RATIO), (int) (-bounds.height * HEIGHT_RATIO)), bounds.getCenter().getTranslated((int) (bounds.width * WIDTH_RATIO), (int) (-bounds.height * OFFSET))); graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * 0.15), (int) (-bounds.height * 0.20)), bounds.getCenter().getTranslated((int) (bounds.width * 0.35), (int) (-bounds.height * 0.10))); graphics.drawLine(bounds.getCenter().getTranslated((int) (bounds.width * 0.35), (int) (-bounds.height * 0.20)), bounds.getCenter().getTranslated((int) (bounds.width * 0.15), (int) (-bounds.height * 0.10))); graphics.popState(); }
Example 10
Source File: LinearScaleTickMarks2.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Draw major ticks for linear scale if {@link isLogScaleEnabled} is false, * otherwise draw major ticks for log scale. * * @param gc * @param ticks * @param tickLabelSide * @param width * @param height * @param isLogScaleEnabled */ private void drawMajorTicks(Graphics gc, ITicksProvider ticks, LabelSide tickLabelSide, int width, int height, boolean isLogScaleEnabled) { int imax = ticks.getMajorCount(); int x, y; if (isLogScaleEnabled) { for (int i = 0; i < imax; i++) { int tickLength = ticks.isVisible(i) ? MAJOR_TICK_LENGTH : MINOR_TICK_LENGTH; x = tickLabelSide == LabelSide.Primary ? width - 1 - LINE_WIDTH - tickLength : LINE_WIDTH; y = height - ticks.getPosition(i); if (ticks.isVisible(i) || getScaleProvider().isMinorTicksVisible()) gc.drawLine(x, y, x + tickLength, y); } } else { x = tickLabelSide == LabelSide.Primary ? width - LINE_WIDTH - MAJOR_TICK_LENGTH : LINE_WIDTH; for (int i = 0; i < imax; i++) { y = height - ticks.getPosition(i); gc.drawLine(x, y, x + MAJOR_TICK_LENGTH, y); } } }
Example 11
Source File: LinearScaleTickMarks2.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Draw the Y tick marks. * * @param tickLabelPositions * the tick label positions * @param tickLabelSide * the side of tick label relative to tick marks * @param width * the width to draw tick marks * @param height * the height to draw tick marks * @param gc * the graphics context */ protected void drawYTickMarks(Graphics gc, List<Integer> tickLabelPositions, LabelSide tickLabelSide, int width, int height) { // draw tick marks gc.setLineStyle(SWTConstants.LINE_SOLID); ITicksProvider ticks = getScaleProvider().getTicksProvider(); if (getScaleProvider().isLogScaleEnabled()) { drawMajorTicks(gc, ticks, tickLabelSide, width, height, true); if (getScaleProvider().isMinorTicksVisible()) { drawMinorTicks(gc, ticks, tickLabelSide, width, height); } } else { drawMajorTicks(gc, ticks, tickLabelSide, width, height, false); if (getScaleProvider().isMinorTicksVisible()) { drawMinorTicks(gc, ticks, tickLabelSide, width, height); } } // draw scale line if (getScaleProvider().isScaleLineVisible()) { if (tickLabelSide == LabelSide.Primary) { gc.drawLine(width - 1, getScaleProvider().getMargin(), width - 1, height - getScaleProvider().getMargin()); } else { gc.drawLine(0, getScaleProvider().getMargin(), 0, height - getScaleProvider().getMargin()); } } }
Example 12
Source File: LinearScaleTickMarks.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void drawYMinorTicks(Graphics gc, LabelSide tickLabelSide, int x, int y) { // there is a misillumiation int verticalMinorTickLength = MINOR_TICK_LENGTH - 1; if (tickLabelSide == LabelSide.Primary) gc.drawLine(x + MAJOR_TICK_LENGTH - verticalMinorTickLength, y, x + MAJOR_TICK_LENGTH, y); else gc.drawLine(x, y, x + verticalMinorTickLength, y); }
Example 13
Source File: BorderForTextAnnotation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public void paint(IFigure figure, Graphics graphics, Insets insets) { tempRect = getPaintRectangle(figure, insets); graphics.setForegroundColor(ColorConstants.black); graphics.setLineWidth(5/*insets.left*/); //paint the left line graphics.drawLine(tempRect.getTopLeft().translate(0, 0), tempRect.getBottomLeft().translate(0, 0)); //paint the top and bottom line graphics.drawLine(tempRect.getTopLeft().translate(0, 0),tempRect.getTopLeft().translate(20, 0) ); graphics.drawLine(tempRect.getBottomLeft().translate(0, -1), tempRect.getBottomLeft().translate(20, -1)); }
Example 14
Source File: StatisticFigure.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void paintChartFrame(Graphics graphics) { graphics.drawLine(marginLeft, getSize().height - marginBottom, getSize().width - marginRight, getSize().height - marginBottom); graphics.drawLine(marginLeft, marginTop, marginLeft, getSize().height - marginBottom); graphics.drawText(Numbers.format(hist.statistics.min, 3), marginLeft, getSize().height - marginBottom + 10); graphics.drawText(Numbers.format(hist.statistics.max, 3), getSize().width - marginRight - 40, getSize().height - marginBottom + 10); graphics.drawText( Integer.toString(hist.getMaxAbsoluteFrequency()), 15, marginTop + 5); graphics.drawText("0", 15, getSize().height - marginBottom - 15); }
Example 15
Source File: LinearScaleTickMarks2.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Draw minor ticks for linear scale or log scale * * @param gc * @param ticks * @param tickLabelSide * @param width * @param height */ private void drawMinorTicks(Graphics gc, ITicksProvider ticks, LabelSide tickLabelSide, int width, int height) { final int end = height - getScaleProvider().getTicksProvider().getTailMargin(); int x = tickLabelSide == LabelSide.Primary ? width - LINE_WIDTH - MINOR_TICK_LENGTH : LINE_WIDTH; int y = 0; final int jmax = ticks.getMinorCount(); for (int j = 0; j < jmax; j++) { y = height - ticks.getMinorPosition(j); if (y >= 0 && y < end) gc.drawLine(x, y, x + MINOR_TICK_LENGTH, y); } }
Example 16
Source File: OverviewCursorFigure.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Override protected void outlineShape(Graphics graphics) { final Rectangle bounds = getBounds(); graphics.setLineStyle(SWT.LINE_DOT); graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft()); }
Example 17
Source File: GridLayer.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void paintGrid(Graphics graphics) { final ITimelineStyleProvider styleProvider = RootFigure.getRootFigure(this).getStyleProvider(); graphics.setLineStyle(styleProvider.getGridLineStyle()); final Rectangle bounds = getBounds(); final Map<Double, Integer> markerPositions = RootFigure.getFigure(this, DetailFigure.class).getMarkerPositions(); for (final int position : markerPositions.values()) graphics.drawLine(position + bounds.x(), bounds.y, position + bounds.x(), bounds.y + bounds.height); }
Example 18
Source File: Annotation.java From nebula with Eclipse Public License 2.0 | 4 votes |
@Override protected void paintFigure(Graphics graphics) { super.paintFigure(graphics); if (trace != null && currentSnappedSample == null && !pointerDragged) updateToDefaultPosition(); if (Preferences.useAdvancedGraphics()) graphics.setAntialias(SWT.ON); Color tempColor; if (annotationColor == null) { tempColor = yAxis.getForegroundColor(); } else tempColor = annotationColor; infoLabel.setForegroundColor(tempColor); pointer.setForegroundColor(tempColor); if (vLine != null) vLine.setForegroundColor(tempColor); if (hLine != null) hLine.setForegroundColor(tempColor); graphics.setForegroundColor(tempColor); if (infoLabelArmed) // draw infoLabel Armed rect graphics.drawRectangle(infoLabel.getBounds()); if (showName || showPosition || showSampleInfo) { // draw indicate line graphics.drawLine(currentPosition.x + (int) dx, currentPosition.y + (int) dy, currentPosition.x, currentPosition.y); // draw Arrow int x1 = (int) (ARROW_LINE_LENGTH * Math.cos(Math.atan(-dy / dx) - Math.PI / 9)); int y1 = (int) (ARROW_LINE_LENGTH * Math.sin(Math.atan(-dy / dx) - Math.PI / 9)); if (dx < 0) { x1 = -x1; y1 = -y1; } graphics.drawLine(currentPosition.x + x1, currentPosition.y - y1, currentPosition.x, currentPosition.y); x1 = (int) (ARROW_LINE_LENGTH * Math.cos(Math.atan(-dy / dx) + Math.PI / 9)); y1 = (int) (ARROW_LINE_LENGTH * Math.sin(Math.atan(-dy / dx) + Math.PI / 9)); if (dx < 0) { x1 = -x1; y1 = -y1; } graphics.drawLine(currentPosition.x + x1, currentPosition.y - y1, currentPosition.x, currentPosition.y); } // draw Cursor Line switch (cursorLineStyle) { case NONE: // left graphics.drawLine(currentPosition.x - POINT_SIZE / 2, currentPosition.y, currentPosition.x - POINT_SIZE / 2 - CURSOR_LINE_LENGTH, currentPosition.y); // right graphics.drawLine(currentPosition.x + POINT_SIZE / 2, currentPosition.y, currentPosition.x + POINT_SIZE / 2 + CURSOR_LINE_LENGTH, currentPosition.y); // up graphics.drawLine(currentPosition.x, currentPosition.y - POINT_SIZE / 2, currentPosition.x, currentPosition.y - POINT_SIZE / 2 - CURSOR_LINE_LENGTH); // down graphics.drawLine(currentPosition.x, currentPosition.y + POINT_SIZE / 2, currentPosition.x, currentPosition.y + POINT_SIZE / 2 + CURSOR_LINE_LENGTH); break; case FOUR_DIRECTIONS: case LEFT_RIGHT: // left graphics.drawLine(currentPosition.x - POINT_SIZE / 2, currentPosition.y, xAxis.getValuePosition(xAxis.getRange().getLower(), false), currentPosition.y); // right graphics.drawLine(currentPosition.x + POINT_SIZE / 2, currentPosition.y, xAxis.getValuePosition(xAxis.getRange().getUpper(), false), currentPosition.y); if (cursorLineStyle != CursorLineStyle.FOUR_DIRECTIONS) break; case UP_DOWN: // up graphics.drawLine(currentPosition.x, currentPosition.y - POINT_SIZE / 2, currentPosition.x, yAxis.getValuePosition(yAxis.getRange().getUpper(), false)); // down graphics.drawLine(currentPosition.x, currentPosition.y + POINT_SIZE / 2, currentPosition.x, yAxis.getValuePosition(yAxis.getRange().getLower(), false)); break; default: break; } }
Example 19
Source File: PagableFreeformRootEditPart.java From ermaster-b with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected void paintGrid(Graphics g) { super.paintGrid(g); Rectangle clip = g.getClip(Rectangle.SINGLETON); PageSetting pageSetting = diagram.getPageSetting(); int width = pageSetting.getWidth(); int height = pageSetting.getHeight(); Rectangle rect = clip; Color color = g.getForegroundColor(); g.setForegroundColor(ColorConstants.lightGray); int startX = rect.x; if (startX > 0) { startX = 0; } int startY = rect.y; if (startY > 0) { startY = 0; } for (int i = startX; i < rect.x + rect.width; i += width) { g.drawLine(i, rect.y, i, rect.y + rect.height); } for (int i = startY; i < rect.y + rect.height; i += height) { g.drawLine(rect.x, i, rect.x + rect.width, i); } g.setForegroundColor(color); i++; if (i > 0) { i = -1; repaint(); } }
Example 20
Source File: StatisticFigure.java From olca-app with Mozilla Public License 2.0 | 4 votes |
private void drawLine(Graphics g, double val, Point box) { int interval = hist.getInterval(val); int x = box.x * interval + marginLeft + box.x / 2; g.drawLine(x, getSize().height - marginBottom, x, marginTop); }