private void setLineAttributes(final int style) { try { gc.setLineAttributes(new LineAttributes(lineWidth, lineCap, lineJoin, style, dashPattern, dashPatternOffset, 10.0f)); } catch (final NoSuchMethodError e) { gc.setLineWidth(lineWidth); gc.setLineCap(lineCap); gc.setLineJoin(lineJoin); if (dashPatternInt == null && dashPattern != null) { this.dashPatternInt = new int[dashPattern.length]; for (int i = 0; i < dashPatternInt.length; i++) { dashPatternInt[i] = (int) dashPattern[i]; } gc.setLineDash(dashPatternInt); } } }
/** * Overridden to translate dashes to printer specific values. * * @see org.eclipse.draw2d.ScaledGraphics#setLineAttributes(org.eclipse.swt.graphics.LineAttributes) */ public void setLineAttributes(LineAttributes attributes) { if (attributes.style == SWT.LINE_CUSTOM && attributes.dash != null && attributes.dash.length > 0) { float[] newDashes = new float[attributes.dash.length]; float printerDot = (float) (printer.getDPI().y / Display.getCurrent().getDPI().y + 0.0000001); for (int i = 0; i < attributes.dash.length; i++) { newDashes[i] = attributes.dash[i] * printerDot; } // make a copy of attributes, we dont's want it changed on figure // (or display will be affected) super.setLineAttributes(new LineAttributes(attributes.width, attributes.cap, attributes.join, attributes.style, newDashes, attributes.dashOffset * printerDot, attributes.miterLimit)); } else { super.setLineAttributes(attributes); } }
/** * Countermeasure against LineAttributes class not having a copy by value * function. * * @since 3.6 */ public static void copyLineAttributes(LineAttributes dest, LineAttributes src) { if (dest != src) { dest.cap = src.cap; dest.join = src.join; dest.miterLimit = src.miterLimit; dest.style = src.style; dest.width = src.width; dest.dashOffset = src.dashOffset; if (src.dash == null) { dest.dash = null; } else { if ((dest.dash == null) || (dest.dash.length != src.dash.length)) { dest.dash = new float[src.dash.length]; } System.arraycopy(src.dash, 0, dest.dash, 0, src.dash.length); } } }
public void setLineStyle(ELineStyle lineStyle) { switch (lineStyle) { case DASHDOT: gc.setLineStyle(SWT.LINE_DASHDOT); break; case SOLID: gc.setLineStyle(SWT.LINE_SOLID); break; case DOT: gc.setLineStyle(SWT.LINE_DOT); break; case PARALLEL: gc.setLineAttributes(new LineAttributes((float) gc.getLineWidth(), SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_CUSTOM, new float[] { 5, 3, }, 0, 10)); break; } }
@Override public void setLineStyle(LineStyle lineStyle) { super.setLineStyle(lineStyle); switch (lineStyle) { case NORMAL: gc.setLineAttributes(lineAttributes); break; case DOT: gc.setLineAttributes(new LineAttributes(1, SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_DOT, null, 0, 10)); break; } }
private void handleDrawRequest(GC gc, int x, int y, int w, int h) { int startLine = fTextWidget.getLineIndex(y); int endLine = fTextWidget.getLineIndex(y + h - 1); if (startLine <= endLine && startLine < fTextWidget.getLineCount()) { Color fgColor = gc.getForeground(); LineAttributes lineAttributes = gc.getLineAttributes(); gc.setForeground(Activator.getDefault().getColor()); gc.setLineStyle(lineStyle); gc.setLineWidth(lineWidth); spaceWidth = gc.getAdvanceWidth(' '); if (fIsAdvancedGraphicsPresent) { int alpha = gc.getAlpha(); gc.setAlpha(this.lineAlpha); drawLineRange(gc, startLine, endLine, x, w); gc.setAlpha(alpha); } else { drawLineRange(gc, startLine, endLine, x, w); } gc.setForeground(fgColor); gc.setLineAttributes(lineAttributes); } }
public void setLineStyle( ELineStyle lineStyle ) { switch ( lineStyle ) { case DASHDOT: gc.setLineStyle( SWT.LINE_DASHDOT ); break; case SOLID: gc.setLineStyle( SWT.LINE_SOLID ); break; case DOT: gc.setLineStyle( SWT.LINE_DOT ); break; case DASH: gc.setLineStyle( SWT.LINE_DASH ); break; case PARALLEL: gc.setLineAttributes( new LineAttributes( gc.getLineWidth(), SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_CUSTOM, new float[] { 5, 3, }, 0, 10 ) ); break; default: break; } }
@Override public void render ( final Graphics g, final Rectangle clientRectangle ) { if ( this.selection != null ) { final Rectangle chartRect = this.chart.getClientAreaProxy ().getClientRectangle (); g.setLineAttributes ( new LineAttributes ( 1.0f ) ); g.setForeground ( null ); g.drawRectangle ( this.selection.x + chartRect.x, this.selection.y + chartRect.y, this.selection.width, this.selection.height ); } }
public YAxisDynamicRenderer ( final ChartRenderer chart ) { super ( chart ); this.chart = chart; this.lineAttributes = new LineAttributes ( 1.0f, SWT.CAP_FLAT, SWT.JOIN_BEVEL, SWT.LINE_SOLID, new float[0], 0.0f, 0.0f ); }
public XAxisDynamicRenderer ( final ChartRenderer chart ) { super ( chart ); this.chart = chart; this.lineAttributes = new LineAttributes ( 1.0f, SWT.CAP_FLAT, SWT.JOIN_BEVEL, SWT.LINE_SOLID, new float[0], 0.0f, 0.0f ); this.labelSpacing = 20; }
public static Image makePreview ( final Display display, final LineAttributes lineAttributes, final Color lineColor, final Point p ) { final Image img = new Image ( display, p.x, p.y ); final GC gc = new GC ( img ); try { gc.setForeground ( img.getDevice ().getSystemColor ( SWT.COLOR_WHITE ) ); gc.setBackground ( img.getDevice ().getSystemColor ( SWT.COLOR_WHITE ) ); gc.fillRectangle ( 0, 0, p.x, p.y ); gc.setLineAttributes ( lineAttributes ); if ( lineColor != null ) { gc.setForeground ( lineColor ); } gc.drawLine ( 0, p.y / 2, p.x, p.y / 2 ); } finally { gc.dispose (); } return img; }
public LevelRuler ( final ChartRenderer manager, final String prefix, final YAxis y, final int style, final int alpha, final float lineWidth ) { this.prefix = prefix; this.manager = manager; this.alpha = alpha; this.ruler = new PositionYRuler ( y, style ); this.ruler.setAlpha ( this.alpha ); this.ruler.setLineAttributes ( new LineAttributes ( lineWidth ) ); this.manager.addRenderer ( this.ruler, 200 ); }
/** * If the line width, line style, foreground or background colors have * changed, these changes will be pushed to the GC. Also calls * {@link #checkGC()}. */ protected final void checkPaint() { checkGC(); if (currentState.fgColor != null) { if (!currentState.fgColor.equals(appliedState.fgColor) && currentState.fgPattern == null) { gc.setForeground(appliedState.fgColor = currentState.fgColor); } } LineAttributes lineAttributes = currentState.lineAttributes; if (!appliedState.lineAttributes.equals(lineAttributes)) { if (getAdvanced()) { gc.setLineAttributes(lineAttributes); } else { gc.setLineWidth((int) lineAttributes.width); gc.setLineCap(lineAttributes.cap); gc.setLineJoin(lineAttributes.join); gc.setLineStyle(lineAttributes.style); if (lineAttributes.dash != null) { gc.setLineDash(convertFloatArrayToInt(lineAttributes.dash)); } } appliedState.lineAttributes = clone(lineAttributes); } if (!currentState.bgColor.equals(appliedState.bgColor) && currentState.bgPattern == null) { gc.setBackground(appliedState.bgColor = currentState.bgColor); } }
/** * Countermeasure against LineAttributes class not having its own clone() * method. * * @since 3.6 */ public static LineAttributes clone(LineAttributes src) { float[] dashClone = null; if (src != null) { if (src.dash != null) { dashClone = new float[src.dash.length]; System.arraycopy(src.dash, 0, dashClone, 0, dashClone.length); } return new LineAttributes(src.width, src.cap, src.join, src.style, dashClone, src.dashOffset, src.miterLimit); } return null; }
/** * Default constructor. * * @since 2.0 */ public Shape() { lineAttributes = new LineAttributes(1.0f); fill = true; outline = true; xorFill = false; xorOutline = false; antialias = null; alpha = null; // synchronize parameters lineWidth = (int) lineAttributes.width; lineStyle = lineAttributes.style; lastLineWidth = lineWidth; }
public void setLineStyle(ELineStyle lineStyle) { switch(lineStyle) { case DASHDOT : gc.setLineStyle(SWT.LINE_DASHDOT); break; case SOLID : gc.setLineStyle(SWT.LINE_SOLID); break; case DOT : gc.setLineStyle(SWT.LINE_DOT); break; case PARALLEL: gc.setLineAttributes(new LineAttributes((float) gc.getLineWidth(), SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_CUSTOM, new float[] { 5, 3, }, 0, 10)); break; } }
@Override public void setLineAttributes ( final LineAttributes lineAttributes ) { this.gc.setLineAttributes ( lineAttributes ); }
public AbstractLineRender ( final ChartRenderer chart, final SeriesData abstractSeriesData ) { super ( chart, abstractSeriesData ); this.lineAttributes = new LineAttributes ( 1.0f ); }
public void setLineAttributes ( final LineAttributes lineAttributes ) { this.lineAttributes = lineAttributes; }
public LineAttributes getLineAttributes () { return this.lineAttributes; }
@Override public void setLineAttributes ( final LineAttributes lineAttributes ) { this.g.setLineAttributes ( lineAttributes ); }
public void setLineWidth(float width) { this.gc.setLineAttributes(new LineAttributes((width == THINNEST_LINE_WIDTH ? 1f : width))); }
public void setLineAttributes(LineAttributes paramLineAttributes) { setLineWidthFloat(paramLineAttributes.width); setLineStyle(paramLineAttributes.style); }
public LineAttributes getLineAttributes() { LineAttributes localLineAttributes; (localLineAttributes = new LineAttributes(getLineWidthFloat())).style = getLineStyle(); return localLineAttributes; }
/** @see Graphics#getLineAttributes() */ public LineAttributes getLineAttributes() { LineAttributes a = graphics.getLineAttributes(); a.width = getLocalLineWidth(); return a; }
/** @see Graphics#setLineAttributes(LineAttributes) */ public void setLineAttributes(LineAttributes attributes) { graphics.setLineAttributes(attributes); setLocalLineWidth(attributes.width); }
/** * @since 3.5 */ public void getLineAttributes(LineAttributes lineAttributes) { copyLineAttributes(lineAttributes, currentState.lineAttributes); }
public void setLineAttributes(LineAttributes lineAttributes) { copyLineAttributes(currentState.lineAttributes, lineAttributes); }
protected void drawLine(GC gc, JobHopMeta hop, boolean is_candidate) { int line[] = getLine(hop.from_entry, hop.to_entry); gc.setLineWidth(linewidth); Color col; if (hop.from_entry.isLaunchingInParallel()) { gc.setLineAttributes(new LineAttributes((float) linewidth, SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_CUSTOM, new float[] { 5, 3, }, 0, 10)); } else { gc.setLineStyle(SWT.LINE_SOLID); } if (is_candidate) { col = GUIResource.getInstance().getColorBlue(); } else if (hop.isEnabled()) { if (hop.isUnconditional()) { col = GUIResource.getInstance().getColorBlack(); } else { if (hop.getEvaluation()) { col = GUIResource.getInstance().getColorGreen(); } else { col = GUIResource.getInstance().getColorRed(); } } } else { col = GUIResource.getInstance().getColorGray(); } gc.setForeground(col); if (hop.isSplit()) gc.setLineWidth(linewidth + 2); drawArrow(gc, line); if (hop.isSplit()) gc.setLineWidth(linewidth); gc.setForeground(GUIResource.getInstance().getColorBlack()); gc.setBackground(GUIResource.getInstance().getColorBackground()); gc.setLineStyle(SWT.LINE_SOLID); }
/** * Sets all line attributes at once. * * @see org.eclipse.swt.graphics.LineAttributes * * @param la * @since 3.5 */ public void setLineAttributes(LineAttributes la) { if (!lineAttributes.equals(la)) { // SWTGraphics.copyLineAttributes(lineAttributes, la); repaint(); } }
/** * Returns the current collection of line attributes. * * @see org.eclipse.swt.graphics.LineAttributes * @return all attributes used for line drawing * @since 3.5 */ public LineAttributes getLineAttributes() { throwNotImplemented(); return null; }
/** * Sets all line attributes together * * @param attributes * the line attributes * @since 3.5 */ public void setLineAttributes(LineAttributes attributes) { throwNotImplemented(); }
/** * Returns line attributes used when drawing this shape. * * @see org.eclipse.swt.graphics.LineAttributes * * Performance note: creates and returns a clone. * * @return current line attributes * @since 3.5 */ public LineAttributes getLineAttributes() { // return SWTGraphics.clone(lineAttributes); return null; }
public void setLineAttributes ( LineAttributes lineAttributes );