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


Java Graphics.setLineWidthFloat方法代码示例

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


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

示例1: draw

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
 * Template method to enforce all standard logic for drawing the shape and its border.
 */
@Override
public final void draw(A shapeAttribute, Graphics graphics, ResourceManager resourceManager) {
  Color stdFgColor = graphics.getForegroundColor();
  Color stdBgColor = graphics.getBackgroundColor();
  float stdLineWidth = graphics.getLineWidthFloat();
  int stdAlpha = graphics.getAlpha();

  try {
    Point tlp = getTopLeftLocation(shapeAttribute);
    Dimension dim = getDimension(shapeAttribute, resourceManager);

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

    float lineWidth = (float) ((DoubleToken) shapeAttribute.lineWidth.getToken()).doubleValue();
    graphics.setLineWidthFloat(lineWidth);

    Rectangle bounds = new Rectangle(tlp.x, tlp.y, dim.width(), dim.height());
    // do the filling of the shape
    graphics.setAlpha(fillColor.getAlpha());
    doFillShape(shapeAttribute, graphics, bounds);
    // draw the border of the shape
    graphics.setAlpha(lineColor.getAlpha());
    doDrawBorder(shapeAttribute, graphics, bounds);
  } catch (IllegalActionException e) {
    getLogger().error("Error reading properties of " + shapeAttribute.getFullName(), e);
  } finally {
    graphics.setLineWidthFloat(stdLineWidth);
    graphics.setForegroundColor(stdFgColor);
    graphics.setBackgroundColor(stdBgColor);
    graphics.setAlpha(stdAlpha);
  }
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:43,代码来源:FilledShapeDrawingStrategy.java

示例2: draw

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
public void draw(ArrowAttribute arrowAttr, Graphics graphics, ResourceManager resourceManager) {
  Color fgColor = graphics.getForegroundColor();
  Color bgColor = graphics.getBackgroundColor();
  Color rgb = getSwtColor(arrowAttr.lineColor, resourceManager);
  if (rgb != null) {
    graphics.setForegroundColor(rgb);
    graphics.setBackgroundColor(rgb);
  }

  try {
    float lineWidth = (float) ((DoubleToken) arrowAttr.lineWidth.getToken()).doubleValue();
    graphics.setLineWidthFloat(lineWidth);
    int x = (int) ((DoubleToken) arrowAttr.x.getToken()).doubleValue();
    int y = (int) ((DoubleToken) arrowAttr.y.getToken()).doubleValue();
    int width = (int) ((DoubleToken) arrowAttr.arrowWidth.getToken()).doubleValue();
    int length = (int) ((DoubleToken) arrowAttr.arrowLength.getToken()).doubleValue();
    int halfWidth = width/2;
    Point tlp = getTopLeftLocation(arrowAttr);
    Transform transform = new Transform();
    transform.setRotation(Math.atan2(y, x));
    PointList pList = new PointList();
    pList.addPoint(0, halfWidth);
    pList.addPoint(length + 3,  0);
    pList.addPoint(length,  halfWidth);
    pList.addPoint((int) Math.sqrt(x*x + y*y),  halfWidth);
    pList.addPoint(length,  halfWidth);
    pList.addPoint(length + 3,  width);
    pList = getTransformedPolygon(transform, pList);
    pList.translate(tlp);
    graphics.fillPolygon(pList);
    graphics.drawPolygon(pList);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading dimensions for " + arrowAttr.getFullName(), e);
  }
  graphics.setForegroundColor(fgColor);
  graphics.setBackgroundColor(bgColor);
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:39,代码来源:ArrowDrawingStrategy.java

示例3: 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

示例4: PageFormatWidget

import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
public PageFormatWidget(Composite parent, int style) {
	super(parent, style);
	setLayout(new GridLayout());
	square = new Canvas(this, SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND);
	GridData gd = new GridData(GridData.FILL_BOTH);
	gd.verticalSpan = 2;
	square.setLayoutData(gd);

	lws = new J2DLightweightSystem();
	lws.setControl(square);
	parentFigure = new Figure();
	parentFigure.setLayoutManager(new XYLayout());
	lws.setContents(parentFigure);

	borderPreview = new RectangleFigure() {

		@Override
		public void paint(Graphics graphics) {
			Dimension psize = parentFigure.getSize();
			float zoom = Math.max((float) pwidth / (float) (psize.width - 20), (float) pheight
					/ (float) (psize.height - 20));

			int x = getBounds().x + 10 + Math.round(lmargin / zoom);
			int y = getBounds().y + 10 + Math.round(tmargin / zoom);
			int w = getBounds().width - 20 - Math.round((rmargin) / zoom) - Math.round(lmargin / zoom);
			int h = getBounds().height - 20 - Math.round((bmargin) / zoom) - Math.round(tmargin / zoom);
			graphics.setForegroundColor(ColorConstants.blue);
			graphics.setBackgroundColor(ColorConstants.lightGray);
			graphics.setLineWidthFloat(0.1f);
			graphics.drawRectangle(x, y, w, h);

			int sw = Math.round(space / zoom);
			w = Math.round((cwidth) / zoom);
			for (int i = 1; i < cols; i++) {
				x += w;
				graphics.drawLine(x, y, x, y + h);
				graphics.fillRectangle(x, y, sw, h);
				x += sw;
				graphics.drawLine(x, y, x, y + h);
			}
			paintBorder(graphics);
		}
	};
	borderPreview.setBorder(new ShadowBorder());
	parentFigure.add(borderPreview);
	Display.getCurrent().asyncExec(new Runnable() {

		public void run() {
			setTBounds();
		}
	});
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:53,代码来源:PageFormatWidget.java


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