本文整理汇总了Java中org.eclipse.swt.graphics.Path类的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于org.eclipse.swt.graphics包,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: arcSelf
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/**
* Paints an looping arc from scr to tgt.
* <p/>
* <b>Assumption:</b> The tgt is located right/below of the src.
*/
public static float[] arcSelf(GC gc, Point src, Point tgt) {
Path path = new Path(gc.getDevice());
int diffH = 10;
int diff = diffH * 3;
path.moveTo((int) src.x, (int) src.y);
path.cubicTo(
(int) src.x + diff, (int) src.y - diffH,
(int) tgt.x, (int) tgt.y - diff,
(int) tgt.x, (int) tgt.y);
gc.drawPath(path);
float[] pp = path.getPathData().points;
return pp;
}
示例2: setClipping
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
@Override
public void setClipping ( final Rectangle rect )
{
if ( rect == null )
{
/*
* As it seems the only way to reset clipping is to set it to null using the Path variant of setClip.
* Since the rectangle version requires an object instance.
*/
this.g.setClip ( (Path)null );
}
else
{
this.g.setClip ( new org.eclipse.draw2d.geometry.Rectangle ( rect.x, rect.y, rect.width, rect.height ) );
}
}
示例3: decrementGCCount
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/**
* Decreases the number of uses of this graphics 2d object.
*/
public static void decrementGCCount() {
CACHE_COUNT--;
if (CACHE_COUNT == 0) {
for (final Iterator i = FONT_CACHE.values().iterator(); i.hasNext();) {
final org.eclipse.swt.graphics.Font font = (org.eclipse.swt.graphics.Font) i.next();
font.dispose();
}
for (final Iterator i = COLOR_CACHE.values().iterator(); i.hasNext();) {
final org.eclipse.swt.graphics.Color color = (org.eclipse.swt.graphics.Color) i.next();
color.dispose();
}
for (final Iterator i = SHAPE_CACHE.values().iterator(); i.hasNext();) {
final Path path = (Path) i.next();
path.dispose();
}
}
}
示例4: paintToImage
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
public static Image paintToImage(DrawableViewNode tree) {
Image image =
new Image(Display.getDefault(), (int) Math.ceil(tree.bounds.width), (int) Math
.ceil(tree.bounds.height));
Transform transform = new Transform(Display.getDefault());
transform.identity();
transform.translate((float) -tree.bounds.x, (float) -tree.bounds.y);
Path connectionPath = new Path(Display.getDefault());
GC gc = new GC(image);
// Can't use Display.getDefault().getSystemColor in a non-UI thread.
Color white = new Color(Display.getDefault(), 255, 255, 255);
Color black = new Color(Display.getDefault(), 0, 0, 0);
gc.setForeground(white);
gc.setBackground(black);
gc.fillRectangle(0, 0, image.getBounds().width, image.getBounds().height);
gc.setTransform(transform);
paintRecursive(gc, transform, tree, null, connectionPath);
gc.drawPath(connectionPath);
gc.dispose();
connectionPath.dispose();
white.dispose();
black.dispose();
return image;
}
示例5: decrementGCCount
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/**
* Decreases the number of uses of this graphics 2d object.
*/
public static void decrementGCCount() {
CACHE_COUNT--;
if (CACHE_COUNT == 0) {
for (final Iterator i = FONT_CACHE.values().iterator(); i.hasNext();) {
final org.eclipse.swt.graphics.Font font = (org.eclipse.swt.graphics.Font) i.next();
font.dispose();
}
FONT_CACHE.clear();
for (final Iterator i = COLOR_CACHE.values().iterator(); i.hasNext();) {
final org.eclipse.swt.graphics.Color color = (org.eclipse.swt.graphics.Color) i.next();
color.dispose();
}
COLOR_CACHE.clear();
for (final Iterator i = SHAPE_CACHE.values().iterator(); i.hasNext();) {
final Path path = (Path) i.next();
path.dispose();
}
SHAPE_CACHE.clear();
}
}
示例6: drawBackground
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
private void drawBackground(final GC gc, final Rectangle rect) {
setBackground(getParent().getBackground());
final GamaUIColor color = GamaColors.get(colorCode);
final Color background = hovered ? color.lighter() : color.color();
final Color foreground = GamaColors.getTextColorForBackground(background).color();
gc.setForeground(foreground);
gc.setBackground(background);
if (down) {
gc.fillRoundRectangle(rect.x + 1, rect.y + 1, rect.width - 2, rect.height - 2, 5, 5);
} else {
final Path path = createClipping(rect);
gc.setClipping(path);
gc.fillRectangle(rect);
gc.setClipping((Rectangle) null);
path.dispose();
}
}
示例7: paintControl
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
@Override
public void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setAntialias(SWT.ON);
Rectangle bounds = getBounds();
Path path = new Path(getDisplay());
path.addArc(bounds.x, bounds.y, arcSize, arcSize, 90, 180);
// path.addRectangle(bounds.x + arcSize / 2, bounds.y, bounds.width - arcSize,
// arcSize);
path.addArc(bounds.x + bounds.width - arcSize, bounds.y, arcSize, arcSize,
270, 180);
// gc.setClipping(path);
Color b = gc.getBackground();
gc.setBackground(backgroundColor);
gc.fillPath(path);
path.dispose();
gc.setAntialias(SWT.OFF);
gc.setBackground(b);
}
示例8: clipPath
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/**
* Simple implementation of clipping a Path within the context of current
* clipping rectangle for now (not region) <li>Note that this method wipes
* out the clipping rectangle area, hence if clients need to reset it call
* {@link #restoreState()}
*
* @see org.eclipse.draw2d.Graphics#clipPath(org.eclipse.swt.graphics.Path)
*/
public void clipPath(Path path) {
initTransform(false);
if (((appliedState.graphicHints ^ currentState.graphicHints) & FILL_RULE_MASK) != 0) {
// If there is a pending change to the fill rule, apply it first.
gc.setFillRule(((currentState.graphicHints & FILL_RULE_MASK) >> FILL_RULE_SHIFT)
- FILL_RULE_WHOLE_NUMBER);
// As long as the FILL_RULE is stored in a single bit, just toggling
// it works.
appliedState.graphicHints ^= FILL_RULE_MASK;
}
Rectangle clipping = currentState.relativeClip != null ? getClip(new Rectangle())
: new Rectangle();
if (!clipping.isEmpty()) {
Path flatPath = new Path(path.getDevice(), path, 0.01f);
PathData pathData = flatPath.getPathData();
flatPath.dispose();
Region region = new Region(path.getDevice());
loadPath(region, pathData.points, pathData.types);
region.intersect(new org.eclipse.swt.graphics.Rectangle(clipping.x,
clipping.y, clipping.width, clipping.height));
gc.setClipping(region);
appliedState.relativeClip = currentState.relativeClip = null;
region.dispose();
}
}
示例9: fillPathColor
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
private final void fillPathColor( Path path, ColorDefinition g )
throws ChartException
{
// skip full transparency for optimization.
if ( !( g.isSetTransparency( ) && g.getTransparency( ) == 0 ) )
{
final Color cBG = (Color) _ids.getColor( g );
final Color cPreviousBG = _gc.getBackground( );
_gc.setBackground( cBG );
R31Enhance.setAlpha( _gc, g );
_gc.fillPath( path );
cBG.dispose( );
_gc.setBackground( cPreviousBG );
}
}
示例10: arc
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/** Paints an arc from src to tgt using the given control point ctr. */
public static float[] arc(GC gc, Point ctr, Point src, Point tgt) {
Path path = new Path(gc.getDevice());
path.moveTo((int) src.x, (int) src.y);
path.quadTo((int) ctr.x, (int) ctr.y, (int) tgt.x, (int) tgt.y);
gc.drawPath(path);
float[] pp = path.getPathData().points;
return pp;
}
示例11: arcReversed
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/**
* Paints an arc from src to tgt.
* <p/>
* <b>Assumption:</b> The tgt is located below of the src.
*/
public static float[] arcReversed(GC gc, Point src, Point tgt) {
Path path = new Path(gc.getDevice());
int ydiff = (int) ((tgt.y - src.y) / 3);
path.moveTo((int) src.x, (int) src.y);
path.cubicTo((int) src.x, (int) src.y + ydiff, (int) tgt.x, (int) tgt.y - ydiff * 2, (int) tgt.x, (int) tgt.y);
gc.drawPath(path);
float[] pp = path.getPathData().points;
return pp;
}
示例12: toSwtPath
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/**
* Converts an AWT <code>Shape</code> into a SWT <code>Path</code>.
*
* @param shape the shape.
*
* @return The path.
*/
private Path toSwtPath(Shape shape) {
int type;
float[] coords = new float[6];
Path path = new Path(this.gc.getDevice());
PathIterator pit = shape.getPathIterator(null);
while (!pit.isDone()) {
type = pit.currentSegment(coords);
switch (type) {
case (PathIterator.SEG_MOVETO):
path.moveTo(coords[0], coords[1]);
break;
case (PathIterator.SEG_LINETO):
path.lineTo(coords[0], coords[1]);
break;
case (PathIterator.SEG_QUADTO):
path.quadTo(coords[0], coords[1], coords[2], coords[3]);
break;
case (PathIterator.SEG_CUBICTO):
path.cubicTo(coords[0], coords[1], coords[2],
coords[3], coords[4], coords[5]);
break;
case (PathIterator.SEG_CLOSE):
path.close();
break;
default:
break;
}
pit.next();
}
return path;
}
示例13: fill
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/** fill an arbitrary shape on the swt graphic composite
* with the current stroke and paint.
* note that for consistency with the awt method, it is needed
* to switch temporarily the foreground and background colors.
* @see java.awt.Graphics2D#fill(java.awt.Shape)
*/
public void fill(Shape shape) {
Path path = toSwtPath(shape);
switchColors();
this.gc.fillPath(path);
switchColors();
path.dispose();
}
示例14: setClip
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
public void setClip(Shape clip) {
if (clip == null)
return;
Path clipPath = toSwtPath(clip);
gc.setClipping(clipPath);
clipPath.dispose();
}
示例15: setClip
import org.eclipse.swt.graphics.Path; //导入依赖的package包/类
/**
* Sets the clip region.
*
* @param clip the clip.
*/
public void setClip(Shape clip) {
if (clip == null) {
return;
}
Path clipPath = toSwtPath(clip);
this.gc.setClipping(clipPath);
clipPath.dispose();
}