Java Code Examples for org.eclipse.draw2d.Graphics#setLineWidth()

The following examples show how to use org.eclipse.draw2d.Graphics#setLineWidth() . 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: ERDiagramLineBorder.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
	if (getColor() != null) {
		graphics.setForegroundColor(getColor());
	}

	tempRect.setBounds(getPaintRectangle(figure, insets));
	if (getWidth() % 2 == 1) {
		tempRect.width--;
		tempRect.height--;
	}
	tempRect.shrink(getWidth() / 2, getWidth() / 2);
	graphics.setLineWidth(1);

	int g = 9 * DELTA;
	int b = 9 * DELTA;

	for (int i = 0; i <= 5; i++) {
		Color color = Resources.getColor(new int[] { b, g, 255 });
		this.paint1(i, color, tempRect, graphics);

		g -= DELTA;
		b -= DELTA;
	}
}
 
Example 2
Source File: PlotArea.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@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 3
Source File: Grid.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void paintFigure(Graphics graphics) {
	super.paintFigure(graphics);
	graphics.pushState();
	if (axis.isShowMajorGrid()) {
		graphics.setLineStyle(axis.isDashGridLine() ? SWTConstants.LINE_DASH : SWTConstants.LINE_SOLID);
		graphics.setForegroundColor(axis.getMajorGridColor());
		graphics.setLineWidth(1);
		for (int pos : axis.getScaleTickLabels().getTickLabelPositions()) {
			if (axis.isHorizontal())
				graphics.drawLine(axis.getBounds().x + pos, bounds.y + bounds.height, axis.getBounds().x + pos,
						bounds.y);
			else
				graphics.drawLine(bounds.x, axis.getBounds().y + axis.getBounds().height - pos,
						bounds.x + bounds.width, axis.getBounds().y + axis.getBounds().height - pos);
		}
	}
	graphics.popState();
}
 
Example 4
Source File: MultipleGuideHandle.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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 5
Source File: RoundedRectangleBorder.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
	tempRect.setBounds(getPaintRectangle(figure, insets));
	if ((getWidth() % 2) == 1) {
		tempRect.width--;
		tempRect.height--;
	}
	tempRect.shrink(getWidth() / 2, getWidth() / 2);

	graphics.setLineWidth(getWidth());
	graphics.setLineStyle(getStyle());
	if (getColor() != null)
		graphics.setForegroundColor(getColor());

	graphics.drawRoundRectangle(tempRect, fArcWidth, fArcHeight);
}
 
Example 6
Source File: LeftRightBorder.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
	tempRect.setBounds(getPaintRectangle(figure, insets));
	if ((getWidth() % 2) == 1) {
		tempRect.width--;
		tempRect.height--;
	}
	tempRect.shrink(getWidth() / 2, getWidth() / 2);
	graphics.setLineWidth(getWidth());
	graphics.setLineStyle(getStyle());
	if (getColor() != null)
		graphics.setForegroundColor(getColor());

	graphics.drawLine(tempRect.getTopLeft(), tempRect.getBottomLeft());
	graphics.drawLine(tempRect.getTopRight(), tempRect.getBottomRight());
}
 
Example 7
Source File: ERDiagramLineBorder.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void paint(final IFigure figure, final Graphics graphics, final Insets insets) {
    if (getColor() != null) {
        graphics.setForegroundColor(getColor());
    }

    tempRect.setBounds(getPaintRectangle(figure, insets));
    if (getWidth() % 2 == 1) {
        tempRect.width--;
        tempRect.height--;
    }
    tempRect.shrink(getWidth() / 2, getWidth() / 2);
    graphics.setLineWidth(1);

    int g = 9 * DELTA;
    int b = 9 * DELTA;

    for (int i = 0; i <= 5; i++) {
        final Color color = Resources.getColor(new int[] {b, g, 255});
        paint1(i, color, tempRect, graphics);

        g -= DELTA;
        b -= DELTA;
    }
}
 
Example 8
Source File: ERDiagramLineBorder.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
    if (getColor() != null) {
        graphics.setForegroundColor(getColor());
    }

    tempRect.setBounds(getPaintRectangle(figure, insets));
    if (getWidth() % 2 == 1) {
        tempRect.width--;
        tempRect.height--;
    }
    tempRect.shrink(getWidth() / 2, getWidth() / 2);
    graphics.setLineWidth(1);

    int g = 9 * DELTA;
    int b = 9 * DELTA;

    for (int i = 0; i <= 5; i++) {
        final Color color = DesignResources.getColor(new int[] { b, g, 255 });
        paint1(i, color, tempRect, graphics);

        g -= DELTA;
        b -= DELTA;
    }
}
 
Example 9
Source File: DropShadowRectangle.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
private void drawShadowLayer(Rectangle rectangle, Graphics graphics,
		int offset, Color color) {

	// Save the state of the graphics object
	graphics.pushState();
	graphics.setLineWidth(0);
	graphics.setBackgroundColor(color);
	Rectangle shadowLayer = new Rectangle(rectangle);
	shadowLayer.x += offset;
	shadowLayer.y += offset;
	graphics.fillRoundRectangle(shadowLayer, corner.width,
			corner.height);
	// Restore the start of the graphics object
	graphics.popState();
}
 
Example 10
Source File: BorderForTextAnnotation.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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 11
Source File: DropShadowRectangle.java    From erflute with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void drawShadowLayer(Rectangle rectangle, Graphics graphics, int offset, Color color) {
    // Save the state of the graphics object
    graphics.pushState();
    graphics.setLineWidth(0);
    graphics.setBackgroundColor(color);
    final Rectangle shadowLayer = new Rectangle(rectangle);
    shadowLayer.x += offset;
    shadowLayer.y += offset;
    graphics.fillRoundRectangle(shadowLayer, corner.width, corner.height);
    // Restore the start of the graphics object
    graphics.popState();
}
 
Example 12
Source File: ExitFigure.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void paint(Graphics graphics) {
	graphics.pushState();
	graphics.setForegroundColor(getForegroundColor());
	graphics.setBackgroundColor(getBackgroundColor());
	super.paint(graphics);
	Path path = new Path(Display.getDefault());
	path.addArc(getBounds().x, getBounds().y, getBounds().width - 1, getBounds().height - 1, 0, 360);
	graphics.setClip(path);
	graphics.setLineWidth(2);
	graphics.drawLine(bounds.getTopLeft(), bounds.getBottomRight());
	graphics.drawLine(bounds.getTopRight(), bounds.getBottomLeft());
	path.dispose();
	graphics.popState();
}
 
Example 13
Source File: DropShadowRectangle.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
private void drawShadowLayer(final Rectangle rectangle, final Graphics graphics, final int offset, final Color color) {

        // Save the state of the graphics object
        graphics.pushState();
        graphics.setLineWidth(0);
        graphics.setBackgroundColor(color);
        final Rectangle shadowLayer = new Rectangle(rectangle);
        shadowLayer.x += offset;
        shadowLayer.y += offset;

        final Dimension cornerDimensions = getCornerDimensions();
        graphics.fillRoundRectangle(shadowLayer, cornerDimensions.width, cornerDimensions.height);
        // Restore the start of the graphics object
        graphics.popState();
    }
 
Example 14
Source File: Trace.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Draw polyline with the line style and line width of the trace.
 * 
 * @param graphics
 * @param pl
 */
private void drawPolyline(Graphics graphics, PointList pl) {
	graphics.pushState();
	graphics.setLineWidth(lineWidth);
	switch (traceType) {
	case SOLID_LINE:
	case STEP_HORIZONTALLY:
	case STEP_VERTICALLY:
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawPolyline(pl);
		break;
	case DASH_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASH);
		graphics.drawPolyline(pl);
		break;
	case DASHDOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASHDOT);
		graphics.drawPolyline(pl);
		break;
	case DASHDOTDOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASHDOTDOT);
		graphics.drawPolyline(pl);
		break;
	case DOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DOT);
		graphics.drawPolyline(pl);
		break;
	default:
		break;
	}
	graphics.popState();
}
 
Example 15
Source File: XYGraphToolbar.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void paintClientArea(Graphics graphics) {
	super.paintClientArea(graphics);
	graphics.setForegroundColor(GRAY_COLOR);
	graphics.setLineWidth(1);
	graphics.drawLine(bounds.x + bounds.width / 2, bounds.y, bounds.x + bounds.width / 2,
			bounds.y + bounds.height);
}
 
Example 16
Source File: Trace.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Draw line with the line style and line width of the trace.
 * 
 * @param graphics
 * @param p1
 * @param p2
 */
public void drawLine(Graphics graphics, Point p1, Point p2) {
	graphics.pushState();
	graphics.setLineWidth(lineWidth);
	switch (traceType) {
	case SOLID_LINE:
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawLine(p1, p2);
		break;
	case BAR:
		if (use_advanced_graphics)
			graphics.setAlpha(areaAlpha);
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawLine(p1, p2);
		break;
	case DASH_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASH);
		graphics.drawLine(p1, p2);
		break;
	case DASHDOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASHDOT);
		graphics.drawLine(p1, p2);
		break;
	case DASHDOTDOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DASHDOTDOT);
		graphics.drawLine(p1, p2);
		break;
	case DOT_LINE:
		graphics.setLineStyle(SWTConstants.LINE_DOT);
		graphics.drawLine(p1, p2);
		break;
	case AREA:
	case LINE_AREA:
		if (traceType == TraceType.LINE_AREA) {
			graphics.setLineStyle(SWTConstants.LINE_SOLID);
			graphics.drawLine(p1, p2);
		}
		int basey;
		switch (baseLine) {
		case NEGATIVE_INFINITY:
			basey = yAxis.getValuePosition(yAxis.getRange().getLower(), false);
			break;
		case POSITIVE_INFINITY:
			basey = yAxis.getValuePosition(yAxis.getRange().getUpper(), false);
			break;
		default:
			basey = yAxis.getValuePosition(0, false);
			break;
		}
		if (use_advanced_graphics)
			graphics.setAlpha(areaAlpha);
		graphics.setBackgroundColor(traceColor);
		graphics.fillPolygon(new int[] { p1.x, p1.y, p1.x, basey, p2.x, basey, p2.x, p2.y });
		break;
	case STEP_HORIZONTALLY:
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawLine(p1.x, p1.y, p2.x, p1.y);
		graphics.drawLine(p2.x, p1.y, p2.x, p2.y);
		break;
	case STEP_VERTICALLY:
		graphics.setLineStyle(SWTConstants.LINE_SOLID);
		graphics.drawLine(p1.x, p1.y, p1.x, p2.y);
		graphics.drawLine(p1.x, p2.y, p2.x, p2.y);
		break;

	default:
		break;
	}
	graphics.popState();
}
 
Example 17
Source File: Trace.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private void drawPoint(Graphics graphics, Point pos, ISample sample) {
	Color renderColor = traceColor;
	PointStyle renderPointStyle = pointStyle;
	int renderPointSize = pointSize;
	try {
		if ((fPointStyleProvider != null) && (sample != null)) {
			renderColor = fPointStyleProvider.getPointColor(sample, this);
			renderPointStyle = fPointStyleProvider.getPointStyle(sample, this);
			renderPointSize = fPointStyleProvider.getPointSize(sample, this);
		}
	} catch (Exception ex) {
		// Draw anyway and log error
		System.err.println(ex.getMessage());
		renderColor = traceColor;
		renderPointStyle = pointStyle;
		renderPointSize = pointSize;
	}
	// Shortcut when no point requested
	if (renderPointStyle == PointStyle.NONE) {
		return;
	}
	graphics.pushState();
	graphics.setBackgroundColor(renderColor);
	graphics.setForegroundColor(renderColor); // Otherwise redraw does not
												// affect lines
	graphics.setLineWidth(1);
	graphics.setLineStyle(SWTConstants.LINE_SOLID);
	int halfSize = renderPointSize / 2;
	switch (renderPointStyle) {
	case POINT:
		graphics.fillOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case CIRCLE:
		graphics.drawOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case FILLED_CIRCLE:
		graphics.fillOval(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case TRIANGLE:
		graphics.drawPolygon(new int[] { pos.x - halfSize, pos.y + halfSize, pos.x, pos.y - halfSize,
				pos.x + halfSize, pos.y + halfSize });
		break;
	case FILLED_TRIANGLE:
		graphics.fillPolygon(new int[] { pos.x - halfSize, pos.y + halfSize, pos.x, pos.y - halfSize,
				pos.x + halfSize, pos.y + halfSize });
		break;
	case SQUARE:
		graphics.drawRectangle(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case FILLED_SQUARE:
		graphics.fillRectangle(new Rectangle(pos.x - halfSize, pos.y - halfSize, renderPointSize, renderPointSize));
		break;
	case BAR:
		graphics.drawLine(pos.x, pos.y - halfSize, pos.x, pos.y + halfSize);
		break;
	case CROSS:
		graphics.drawLine(pos.x, pos.y - halfSize, pos.x, pos.y + halfSize);
		graphics.drawLine(pos.x - halfSize, pos.y, pos.x + halfSize, pos.y);
		break;
	case XCROSS:
		graphics.drawLine(pos.x - halfSize, pos.y - halfSize, pos.x + halfSize, pos.y + halfSize);
		graphics.drawLine(pos.x + halfSize, pos.y - halfSize, pos.x - halfSize, pos.y + halfSize);
		break;
	case DIAMOND:
		graphics.drawPolyline(new int[] { pos.x, pos.y - halfSize, pos.x - halfSize, pos.y,
				pos.x, pos.y + halfSize, pos.x + halfSize, pos.y, pos.x, pos.y - halfSize });
		break;
	case FILLED_DIAMOND:
		graphics.fillPolygon(new int[] { pos.x, pos.y - halfSize, pos.x - halfSize, pos.y,
				pos.x, pos.y + halfSize, pos.x + halfSize, pos.y });
		break;
	default:
		break;
	}
	graphics.popState();
}
 
Example 18
Source File: Axis.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void paintClientArea(final Graphics graphics) {
	// Don't do anything when hidden
	if (!isVisible())
		return;

	super.paintClientArea(graphics);

	// graphics.pushState();
	if (title != null) {
		graphics.setFont(titleFont);
		final Dimension titleSize = FigureUtilities.getTextExtents(title, titleFont);
		if (isHorizontal()) {
			if (getTickLabelSide() == LabelSide.Primary)
				graphics.drawText(title, bounds.x + bounds.width / 2 - titleSize.width / 2,
						bounds.y + bounds.height - titleSize.height);
			else
				graphics.drawText(title, bounds.x + bounds.width / 2 - titleSize.width / 2, bounds.y);
		} else {
			final int w = titleSize.height;
			final int h = titleSize.width + 1;

			if (getTickLabelSide() == LabelSide.Primary) {
				GraphicsUtil.drawVerticalText(graphics, title, bounds.x, bounds.y + bounds.height / 2 - h / 2,
						false);
			} else {
				GraphicsUtil.drawVerticalText(graphics, title, bounds.x + bounds.width - w,
						bounds.y + bounds.height / 2 - h / 2, true);
			}
		}
	}
	// graphics.popState();

	// Show the start/end cursor or the 'rubberband' of a zoom operation?
	if (armed && end != null && start != null) {
		switch (zoomType) {
		case RUBBERBAND_ZOOM:
		case HORIZONTAL_ZOOM:
		case VERTICAL_ZOOM:
		case DYNAMIC_ZOOM:
			graphics.setLineStyle(SWTConstants.LINE_DOT);
			graphics.setLineWidth(1);
			graphics.setForegroundColor(revertBackColor);
			graphics.drawRectangle(start.x, start.y, end.x - start.x - 1, end.y - start.y - 1);
			break;

		default:
			break;
		}
	}
}