当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.setLineStyle方法代码示例

本文整理汇总了Java中org.eclipse.draw2d.Graphics.setLineStyle方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.setLineStyle方法的具体用法?Java Graphics.setLineStyle怎么用?Java Graphics.setLineStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.draw2d.Graphics的用法示例。


在下文中一共展示了Graphics.setLineStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@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();
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:20,代码来源:Grid.java

示例2: drawPolyline

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
	 * 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;
	default:
		break;
	}
	graphics.popState();
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:26,代码来源:Trace.java

示例3: paint

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void paint(IFigure figure, Graphics graphics, Insets insets) {
	Rectangle r = getPaintRectangle(figure, insets);

	graphics.setLineWidth(getWidth());
	graphics.setLineStyle(getStyle());
	if (getColor() != null)
		graphics.setForegroundColor(getColor());
	int y1 = r.y + getWidth() / 2;
	int x2 = r.x + r.width;
	graphics.drawLine(r.x, y1, x2, y1);
	y1 = r.y + r.height - getWidth() / 2;
	graphics.drawLine(r.x, y1, x2, y1);

	graphics.setLineWidth(1);
	graphics.drawLine(r.x - 10, r.y, r.x - 10, r.y + r.height);
	graphics.drawLine(r.x + r.width, r.y, r.x + r.width, r.y + r.height);
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:19,代码来源:TBLineBorder.java

示例4: drawArrow

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawArrow(Graphics g, Point from, Point to) {
	g.setLineStyle(Graphics.LINE_SOLID);
	g.drawLine(from, to);

	int yy = from.y < to.y ? -ARROW_EDGE : ARROW_EDGE;
	g.drawLine(to, to.getTranslated(-ARROW_EDGE, yy));
	g.drawLine(to, to.getTranslated(ARROW_EDGE, yy));
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:9,代码来源:ValueFigure.java

示例5: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics graphics) {
	super.paintFigure(graphics);
	graphics.setForegroundColor(error ? Constants.Colors.ERROR : ColorConstants.gray);
	graphics.setLineWidth(Constants.ARRAY_LINE_WIDTH);
	graphics.setLineDashOffset(2.5f);
	graphics.setLineStyle(Graphics.LINE_DASH);
	graphics.drawRectangle(getLocation().x, getLocation().y + TOP_PADDING, POSITION_WIDTH-1, POSITION_WIDTH-1);
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:10,代码来源:ArrayPrimitiveFigure.java

示例6: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * Override to render the circle without background and with dotted outline
 */
@Override 
protected void paintFigure(Graphics graphics) {
	Rectangle bounds = getBounds().getCopy();
	Rectangle realBounds = bounds.getCopy();
	
	int offset = (int)(HIDDEN_CHILDREN_INDICATOR_SIZE * 0.5);
	bounds.setY(bounds.y + offset);
	bounds.setHeight(bounds.width);
	
	//Compensate for line width
	int lineWidth = outlineWidth / 2;
	bounds.expand(-lineWidth, -lineWidth);

	DEGraphicalEditorTheme theme = DEGraphicalEditor.getTheme();
			
	graphics.setLineStyle(SWT.LINE_CUSTOM);
	graphics.setLineDash(new int[] {4});
	graphics.setLineWidth(theme.getLineWidth());
	graphics.setForegroundColor(theme.getLineColor());

	Point topLeft = realBounds.getTopLeft();
	Point bottomLeft = realBounds.getBottomLeft();
	graphics.drawLine(new Point(topLeft.x+offset-theme.getLineWidth() / 2, topLeft.y), 
					  new Point(bottomLeft.x+offset-theme.getLineWidth() / 2, bottomLeft.y-HIDDEN_CHILDREN_INDICATOR_SIZE));


	DEDrawingUtil.outlineEllipsis(graphics, bounds, outlineColor);		
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:32,代码来源:DwHiddenChildrenIndicatorFigure.java

示例7: paint

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void paint(IFigure figure, Graphics g, Insets in) {
	Rectangle r = figure.getBounds().getCropped(in);
	g.setLineStyle(Graphics.LINE_DASHDOT);
	g.setLineWidth(3);
	g.setForegroundColor(selectedColor);
	g.drawLine(r.x, r.y , r.right() , r.y );
	g.drawLine(r.x, r.bottom(), r.right(), r.bottom());
	g.drawLine(r.x, r.y, r.x, r.bottom());
	g.drawLine(r.right(), r.bottom(), r.right() , r.y );
	r.crop(getInsets(figure));
}
 
开发者ID:ShoukriKattan,项目名称:ForgedUI-Eclipse,代码行数:13,代码来源:FeedbackBorder.java

示例8: draw

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void draw(LineAttribute lineAttr, Graphics graphics, ResourceManager resourceManager) {
  Color stdFgColor = graphics.getForegroundColor();
  int stdLineStyle = graphics.getLineStyle();

  Color lineColor = getSwtColor(lineAttr.lineColor, resourceManager);
  if (lineColor != null) {
    graphics.setForegroundColor(lineColor);
  }

  try {
    float lineWidth = (float) ((DoubleToken) lineAttr.lineWidth.getToken()).doubleValue();
    graphics.setLineWidthFloat(lineWidth);
    int x2_step = (int) ((DoubleToken) lineAttr.x.getToken()).doubleValue();
    int y2_step = (int) ((DoubleToken) lineAttr.y.getToken()).doubleValue();

    // TODO may need to move this upwards as other shape types may also have dashed lines in Ptolemy II
    ArrayToken dashArrayToken = (ArrayToken) lineAttr.dashArray.getToken();
    if (dashArrayToken != null && dashArrayToken.length() > 0) {
      graphics.setLineStyle(SWT.LINE_DASH);
      float[] dashPattern = new float[dashArrayToken.length()];
      for (int i = 0; i < dashArrayToken.length(); i++) {
        dashPattern[i] = (float) ((DoubleToken) dashArrayToken.getElement(i)).doubleValue();
      }
      graphics.setLineDash(dashPattern);
    }
    Point tlp = getTopLeftLocation(lineAttr);
    graphics.drawLine(tlp, tlp.getTranslated(x2_step, y2_step));
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading dimensions for " + lineAttr.getFullName(), e);
  } finally {
    graphics.setForegroundColor(stdFgColor);
    graphics.setLineStyle(stdLineStyle);
  }
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:36,代码来源:LineDrawingStrategy.java

示例9: paintClientArea

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@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 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;
		}
	}
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:29,代码来源:PlotArea.java

示例10: paintFigure

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintFigure(Graphics g) {
	g.setLineStyle(Graphics.LINE_DOT);
	g.setXORMode(true);
	g.setForegroundColor(ColorConstants.black);
	if (bounds.width > bounds.height) {
		g.drawLine(bounds.x, bounds.y, bounds.right(), bounds.y);
		g.drawLine(bounds.x + 2, bounds.y, bounds.right(), bounds.y);
	} else {
		g.drawLine(bounds.x, bounds.y, bounds.x, bounds.bottom());
		g.drawLine(bounds.x, bounds.y + 2, bounds.x, bounds.bottom());
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:13,代码来源:JDGuideEditPart.java

示例11: setIllustrationStyle

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void setIllustrationStyle(Graphics g) {
	g.setLineWidth(PandionJConstants.ILLUSTRATION_LINE_WIDTH);
	g.setLineDashOffset(2.5f);
	g.setLineStyle(Graphics.LINE_SOLID);
	g.setForegroundColor(PandionJConstants.Colors.ILLUSTRATION);
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:7,代码来源:IllustrationBorder.java

示例12: paintClientArea

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
	protected void paintClientArea(final Graphics graphics) {
		// Don't do anything when hidden
		if (!isVisible())
			return;

		super.paintClientArea(graphics);

//		graphics.pushState();
		graphics.setFont(titleFont);
		final Dimension titleSize = FigureUtilities.getTextExtents(title, titleFont);
		if(isHorizontal()){
			if(getTickLablesSide() == 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(getTickLablesSide() == 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:
				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;
			}
		}
	}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:53,代码来源:Axis.java

示例13: drawErrorBar

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawErrorBar(Graphics graphics, Point dpPos, ISample dp) {
	graphics.pushState();
	graphics.setForegroundColor(errorBarColor);
	graphics.setLineStyle(SWTConstants.LINE_SOLID);
	graphics.setLineWidth(1);
	Point ep;
	switch (yErrorBarType) {
	case BOTH:
	case MINUS:
		ep = new Point(xAxis.getValuePosition(dp.getXValue(), false),
				yAxis.getValuePosition(
						dp.getYValue() - dp.getYMinusError(), false));
		graphics.drawLine(dpPos, ep);
		graphics.drawLine(ep.x - errorBarCapWidth / 2, ep.y, ep.x
				+ errorBarCapWidth / 2, ep.y);
		if (yErrorBarType != ErrorBarType.BOTH)
			break;
	case PLUS:
		ep = new Point(xAxis.getValuePosition(dp.getXValue(), false),
				yAxis.getValuePosition(dp.getYValue() + dp.getYPlusError(),
						false));
		graphics.drawLine(dpPos, ep);
		graphics.drawLine(ep.x - errorBarCapWidth / 2, ep.y, ep.x
				+ errorBarCapWidth / 2, ep.y);
		break;
	default:
		break;
	}

	switch (xErrorBarType) {
	case BOTH:
	case MINUS:
		ep = new Point(xAxis.getValuePosition(
				dp.getXValue() - dp.getXMinusError(), false),
				yAxis.getValuePosition(dp.getYValue(), false));
		graphics.drawLine(dpPos, ep);
		graphics.drawLine(ep.x, ep.y - errorBarCapWidth / 2, ep.x, ep.y
				+ errorBarCapWidth / 2);
		if (xErrorBarType != ErrorBarType.BOTH)
			break;
	case PLUS:
		ep = new Point(xAxis.getValuePosition(
				dp.getXValue() + dp.getXPlusError(), false),
				yAxis.getValuePosition(dp.getYValue(), false));
		graphics.drawLine(dpPos, ep);
		graphics.drawLine(ep.x, ep.y - errorBarCapWidth / 2, ep.x, ep.y
				+ errorBarCapWidth / 2);
		break;
	default:
		break;
	}

	graphics.popState();
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:55,代码来源:Trace.java

示例14: drawPoint

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * Draw point with the pointStyle and size of the trace;
 * 
 * @param graphics
 * @param pos
 */
public void drawPoint(Graphics graphics, Point pos) {
	// Shortcut when no point requested
	if (pointStyle == PointStyle.NONE)
		return;
	graphics.pushState();
	graphics.setBackgroundColor(traceColor);
	// graphics.setForegroundColor(traceColor);
	graphics.setLineWidth(1);
	graphics.setLineStyle(SWTConstants.LINE_SOLID);
	switch (pointStyle) {
	case POINT:
		graphics.fillOval(new Rectangle(pos.x - pointSize / 2, pos.y
				- pointSize / 2, pointSize, pointSize));
		break;
	case CIRCLE:
		graphics.drawOval(new Rectangle(pos.x - pointSize / 2, pos.y
				- pointSize / 2, pointSize, pointSize));
		break;
	case TRIANGLE:
		graphics.drawPolygon(new int[] { pos.x - pointSize / 2,
				pos.y + pointSize / 2, pos.x, pos.y - pointSize / 2,
				pos.x + pointSize / 2, pos.y + pointSize / 2 });
		break;
	case FILLED_TRIANGLE:
		graphics.fillPolygon(new int[] { pos.x - pointSize / 2,
				pos.y + pointSize / 2, pos.x, pos.y - pointSize / 2,
				pos.x + pointSize / 2, pos.y + pointSize / 2 });
		break;
	case SQUARE:
		graphics.drawRectangle(new Rectangle(pos.x - pointSize / 2, pos.y
				- pointSize / 2, pointSize, pointSize));
		break;
	case FILLED_SQUARE:
		graphics.fillRectangle(new Rectangle(pos.x - pointSize / 2, pos.y
				- pointSize / 2, pointSize, pointSize));
		break;
	case BAR:
		graphics.drawLine(pos.x, pos.y - pointSize / 2, pos.x, pos.y
				+ pointSize / 2);
		break;
	case CROSS:
		graphics.drawLine(pos.x, pos.y - pointSize / 2, pos.x, pos.y
				+ pointSize / 2);
		graphics.drawLine(pos.x - pointSize / 2, pos.y, pos.x + pointSize
				/ 2, pos.y);
		break;
	case XCROSS:
		graphics.drawLine(pos.x - pointSize / 2, pos.y - pointSize / 2,
				pos.x + pointSize / 2, pos.y + pointSize / 2);
		graphics.drawLine(pos.x + pointSize / 2, pos.y - pointSize / 2,
				pos.x - pointSize / 2, pos.y + pointSize / 2);
		break;
	case DIAMOND:
		graphics.drawPolyline(new int[] { pos.x, pos.y - pointSize / 2,
				pos.x - pointSize / 2, pos.y, pos.x, pos.y + pointSize / 2,
				pos.x + pointSize / 2, pos.y, pos.x, pos.y - pointSize / 2 });
		break;
	case FILLED_DIAMOND:
		graphics.fillPolygon(new int[] { pos.x, pos.y - pointSize / 2,
				pos.x - pointSize / 2, pos.y, pos.x, pos.y + pointSize / 2,
				pos.x + pointSize / 2, pos.y });
		break;
	default:
		break;
	}
	graphics.popState();
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:74,代码来源:Trace.java

示例15: drawLine

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * 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 AREA:
		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();
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:63,代码来源:Trace.java


注:本文中的org.eclipse.draw2d.Graphics.setLineStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。