@Override protected void paintFigure(Graphics g) { super.paintFigure(g); final int LEG = 5; Rectangle r = getBounds(); g.setLineWidth(1); g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR); g.drawLine(r.x, r.y, r.x, r.y+r.height-1); g.drawLine(r.x, r.y, r.x+LEG, r.y); g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1); g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height); g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y); g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1); if(!valid) { g.setForegroundColor(PandionJConstants.Colors.ERROR); String text = "Invalid matrix"; int textWidth = FigureUtilities.getTextWidth(text, g.getFont()); Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5); g.drawText(text, p); } }
public void relocate(CellEditor celleditor) { Text text = (Text) celleditor.getControl(); Rectangle rect = null; if(bounds == null) { rect = figure.getBounds().getCopy(); } else { rect = bounds.getCopy(); } figure.translateToAbsolute(rect); org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0); rect.translate(trim.x, trim.y); rect.width += trim.width; rect.height = HEIGHT; if (text.getFont() != null){ rect.height = FigureUtilities.getStringExtents("T", text.getFont()).height + 4; } text.setBounds(rect.x, rect.y - rect.height, rect.width, rect.height); }
protected void paintMessage(Graphics graphics, Rectangle parentRect) { String message = Utils.getString(this.message, ""); List<String> text = SWTWordWrap.wrap(message, resolution.width - 24, graphics.getFont()); if (text != null && text.size() > 0){ int oneLineHeight = getMargin() + FigureUtilities.getStringExtents("X", graphics.getFont()).height; graphics.pushState(); graphics.clipRect(parentRect); int y = parentRect.y; for (int i = 0; y < parentRect.bottom() && i < text.size(); i++) { Rectangle lineRect = new Rectangle(parentRect.x, y, parentRect.width, oneLineHeight + getMargin()); Drawer.drawString(graphics, text.get(i), lineRect, Alignments.left, Alignments.top, getMargin()); y += oneLineHeight; } graphics.popState(); } }
@Override protected Dimension getDimension(TextAttribute textAttr, ResourceManager resourceManager) { try { String text = textAttr.text.getExpression(); int fontSize = ((IntToken) textAttr.textSize.getToken()).intValue(); String fontFamily = textAttr.fontFamily.stringValue(); boolean italic = ((BooleanToken) textAttr.italic.getToken()).booleanValue(); boolean bold = ((BooleanToken) textAttr.bold.getToken()).booleanValue(); int style = SWT.NORMAL | (italic ? SWT.ITALIC : SWT.NORMAL) | (bold ? SWT.BOLD : SWT.NORMAL); Font f = resourceManager.createFont(FontDescriptor.createFrom(fontFamily, fontSize, style)); return FigureUtilities.getTextExtents(text, f); } catch (IllegalActionException e) { LOGGER.error("Error reading dimensions for " + textAttr.getFullName(), e); return new Dimension(0, 0); } }
/** * Returns the state indicating if there is a space to draw tick label. * * @param previousPosition * the previously drawn tick label position. * @param tickLabelPosition * the tick label position. * @param previousTickLabel * the prevoius tick label. * @param tickLabel * the tick label text * @return true if there is a space to draw tick label */ private boolean hasSpaceToDraw(int previousPosition, int tickLabelPosition, String previousTickLabel, String tickLabel) { Dimension tickLabelSize = FigureUtilities.getTextExtents(tickLabel, scale.getFont()); Dimension previousTickLabelSize = FigureUtilities.getTextExtents(previousTickLabel, scale.getFont()); int interval = tickLabelPosition - previousPosition; int textLength = (int) (scale.isHorizontal() ? (tickLabelSize.width/2.0 + previousTickLabelSize.width/2.0) : tickLabelSize.height); boolean noLapOnPrevoius = true; boolean noLapOnEnd = true; if(tickLabelPosition != tickLabelPositions.get(tickLabelPositions.size() - 1)){ //if it is not the end tick label. noLapOnPrevoius = interval > (textLength+TICK_LABEL_GAP); Dimension endTickLabelSize = FigureUtilities.getTextExtents( tickLabels.get(tickLabels.size()-1), scale.getFont()); interval = tickLabelPositions.get(tickLabelPositions.size() - 1) - tickLabelPosition; textLength = (int) (scale.isHorizontal() ? (tickLabelSize.width/2.0 + endTickLabelSize.width/2.0) : tickLabelSize.height); noLapOnEnd = interval > textLength+TICK_LABEL_GAP; } return noLapOnPrevoius && noLapOnEnd; }
/** * Gets max length of tick label. */ private void updateTickLabelMaxLengthAndHeight() { int maxLength = 0; int maxHeight = 0; for (int i = 0; i < tickLabels.size(); i++) { if (tickVisibilities.size() > i && tickVisibilities.get(i) == true) { Dimension p = FigureUtilities.getTextExtents(tickLabels.get(i), scale.getFont()); if (tickLabels.get(0).startsWith("-") && !tickLabels.get(i).startsWith("-")) { p.width += FigureUtilities.getTextExtents("-", getFont()).width; } if (p.width > maxLength) { maxLength = p.width; } if(p.height > maxHeight){ maxHeight = p.height; } } } tickLabelMaxLength = maxLength; tickLabelMaxHeight = maxHeight; }
/** * Draw the Y tick. * * @param grahpics * the graphics context */ private void drawYTick(Graphics grahpics) { // draw tick labels grahpics.setFont(scale.getFont()); int fontHeight = tickLabelMaxHeight; for (int i = 0; i < tickLabelPositions.size(); i++) { if (tickVisibilities.size() == 0 || tickLabels.size() == 0) { break; } if (tickVisibilities.get(i) == true) { String text = tickLabels.get(i); int x = 0; if (tickLabels.get(0).startsWith("-") && !text.startsWith("-")) { x += FigureUtilities.getTextExtents("-", getFont()).width; } int y = (int) Math.ceil(scale.getLength() - tickLabelPositions.get(i) - fontHeight / 2.0); grahpics.drawText(text, x, y); } } }
/** * @return the markerValues */ public void updateMarkerElments() { labels = new String[markersMap.size()]; markerColorsList.clear(); markerValues = new double[markersMap.size()]; markerLabelDimensions = new Dimension[markersMap.size()]; markerPositions = new int[markerValues.length]; int i = 0; for(String label : markersMap.keySet()) { labels[i] = label; markerValues[i] = markersMap.get(label).value; markerPositions[i] = scale.getValuePosition(markerValues[i], true); markerLabelDimensions[i] = FigureUtilities.getTextExtents(label, getFont()); markerColorsList.add( XYGraphMediaFactory.getInstance().getColor(markersMap.get(label).color)); i++; } }
@Override public Dimension getPreferredSize(int wHint, int hHint) { updateTick(); Dimension size = new Dimension(wHint, hHint); if(scale.isHorizontal()) { size.width = scale.getSize().width; size.height = FigureUtilities.getTextExtents("dummy", getFont()).height + GAP_BTW_MARK_LABEL + TICK_LENGTH; } else { updateTickLabelMaxLength(); size.width = (int)tickLabelMaxLength + GAP_BTW_MARK_LABEL + TICK_LENGTH; size.height = scale.getSize().height; } return size; }
@Override public Dimension getPreferredSize(int wHint, int hHint) { int maxWidth =0; int hEnd = INNER_GAP; int height = ICON_WIDTH + INNER_GAP; // int i=0; for(Trace trace : traceList){ hEnd = hEnd + OUT_GAP + ICON_WIDTH + INNER_GAP + + FigureUtilities.getTextExtents(trace.getName(), getFont()).width; if(hEnd > wHint){ hEnd= INNER_GAP + OUT_GAP + ICON_WIDTH + INNER_GAP + + FigureUtilities.getTextExtents(trace.getName(), getFont()).width; height += ICON_WIDTH + INNER_GAP; } if(maxWidth < hEnd) maxWidth = hEnd; // i++; } return new Dimension(maxWidth, height); }
/** * Creates the <code>Text</code> where the description of the entry is to be * displayed. * * @param panel * The Composite in which the <code>Text</code> is to be created * @return The newly created <code>Text</code> */ protected Text createDescText(Composite panel) { String desc = entry.getDescription(); Text description = createText(panel, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, desc); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = 150; data.heightHint = description.computeTrim(0, 0, 10, FigureUtilities .getFontMetrics(description.getFont()).getHeight() * 2).height; description.setLayoutData(data); if (getPermission() >= PaletteEntry.PERMISSION_LIMITED_MODIFICATION) { description.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { handleDescriptionChanged(((Text) e.getSource()).getText()); } }); } return description; }
/** * @generated */ public void relocate(CellEditor celleditor) { Text text = (Text) celleditor.getControl(); Rectangle rect = getWrapLabel().getTextBounds().getCopy(); getWrapLabel().translateToAbsolute(rect); if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) { rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT))); } else { int avr = FigureUtilities.getFontMetrics(text.getFont()) .getAverageCharWidth(); rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0)); } if (!rect.equals(new Rectangle(text.getBounds()))) { text.setBounds(rect.x, rect.y, rect.width, rect.height); } }
protected void updateInfomation(String label) { if (infoLabel == null) { return; } infoLabel.setText( label ); Dimension size = FigureUtilities.getTextExtents( label, infoLabel.getFont( ) ); //Insets insets = getInfomationLabel( ).getInsets( ); Insets insets = INSETS; Dimension newSize = size.getCopy( ).expand( insets.getWidth( ), insets.getHeight( ) ) ; if (size.width > maxWidth) { maxWidth = size.width; } else { newSize = new Dimension(maxWidth, size.height).expand( insets.getWidth( ), insets.getHeight( ) ); } infoLabel.setSize( newSize); setLabelLocation( ); adjustLocation( ); }
private boolean canDrawNumber(String num, Point startPoint ,Graphics g) { Transposer transposer = new Transposer(); transposer.setEnabled( !isHorizontal() ); Rectangle rect = transposer.t( g.getClip( Rectangle.SINGLETON )); Dimension strSize = FigureUtilities.getStringExtents(num, getFont()); startPoint = transposer.t(startPoint); if (strSize.width + startPoint.x > rect.x + rect.width) { return false; } rect = transposer.t( getEndRect( g .getClip( Rectangle.SINGLETON ) )); if (rect.width == 0) { return true; } if (strSize.width + startPoint.x > rect.x) { return false; } return true; }
protected Dimension calculateIndicatorDimension( Font font, int width ) { gap = 0; Dimension iconDimension = new Dimension( ); if ( image != null ) { iconDimension = new Dimension( image ); gap = 2; } Dimension d = FigureUtilities.getTextExtents( indicatorLabel, font ); int incheight = 0; if ( iconDimension.height > d.height ) { incheight = iconDimension.height - d.height; } d.expand( iconDimension.width + gap + gapInsets.left + gapInsets.right + 2 * width + 2, incheight + gapInsets.top + gapInsets.bottom ); return d; }
private Dimension calculateIndicatorDimension( Graphics g, int width ) { gap = 0; Dimension iconDimension = new Dimension( ); if ( image != null ) { iconDimension = new Dimension( image ); gap = 2; } Dimension d = FigureUtilities.getTextExtents( indicatorLabel, g.getFont( ) ); int incheight = 0; if ( iconDimension.height > d.height ) { incheight = iconDimension.height - d.height; } d.expand( iconDimension.width + gap + gapInsets.left + gapInsets.right + 2 * width + 2, incheight + gapInsets.top + gapInsets.bottom ); return d; }
private void paintSpecial_old( Graphics g, String text, int x, int y, boolean firstBox ) { if ( firstBox && specialPREFIX.length( ) != 0 && text.indexOf( specialPREFIX ) == 0 ) { int with = FigureUtilities.getTextWidth( specialPREFIX, g.getFont( ) ); Color c = g.getForegroundColor( ); g.setForegroundColor( ReportColorConstants.textFillColor ); g.drawString( specialPREFIX, x, y ); g.setForegroundColor( c ); g.drawString( text.substring( specialPREFIX.length( ) ), x + with, y ); } else { g.drawString( text, x, y ); } }
public void updateInfomation(String label, Point p) { if (labelFigure == null) { return; } labelFigure.setText( label ); Dimension size = FigureUtilities.getTextExtents( label, labelFigure.getFont( ) ); //Insets insets = getInfomationLabel( ).getInsets( ); Insets insets = INSETS; Dimension newSize = size.getCopy( ).expand( insets.getWidth( ), insets.getHeight( ) ) ; if (size.width > maxWidth) { maxWidth = size.width; } else { newSize = new Dimension(maxWidth, size.height).expand( insets.getWidth( ), insets.getHeight( ) ); } labelFigure.setSize( newSize); setLabelLocation( p ); adjustLocation( p ); }
public void relocate(IFigure figure) { Dimension minimum = FigureUtilities.getTextExtents(text, figure.getFont()); figure.setSize(minimum); Point location = polyline.getPoints().getMidpoint(); Point offsetCopy = offset.getCopy(); offsetCopy.translate(location); figure.setLocation(offsetCopy); }
private void setAutoFont(int size, String text, FontStyle ... styles) { Font f = FontManager.getFont(size, styles); while(FigureUtilities.getTextWidth(text, f) > PandionJConstants.POSITION_WIDTH-4 && size > 8) { size--; f = FontManager.getFont(size, styles); } setFont(f); }
@Override public void showTargetFeedback(final Request request) { final ERDiagram diagram = (ERDiagram) getHost().getRoot().getContents().getModel(); if (diagram.isTooltip()) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final TableView tableView = (TableView) getHost().getModel(); final Rectangle tableBounds = getHostFigure().getBounds(); final String name = TableViewEditPart.getTableViewName(tableView, diagram); final Label label = new Label(); label.setText(name); label.setBorder(new SimpleRaisedBorder()); label.setBackgroundColor(ColorConstants.orange); label.setOpaque(true); final Dimension dim = FigureUtilities.getTextExtents(name, Display.getCurrent().getSystemFont()); label.setBounds(new Rectangle((int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20)); addFeedback(label); } super.showTargetFeedback(request); }
@Override public void showTargetFeedback(Request request) { ERDiagram diagram = (ERDiagram) this.getHost().getRoot().getContents() .getModel(); if (diagram.isTooltip()) { ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); TableView tableView = (TableView) this.getHost().getModel(); Rectangle tableBounds = this.getHostFigure().getBounds(); String name = TableViewEditPart.getTableViewName(tableView, diagram); Label label = new Label(); label.setText(name); label.setBorder(new SimpleRaisedBorder()); label.setBackgroundColor(ColorConstants.orange); label.setOpaque(true); Dimension dim = FigureUtilities.getTextExtents(name, Display .getCurrent().getSystemFont()); label.setBounds(new Rectangle((int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20)); this.addFeedback(label); } super.showTargetFeedback(request); }
@Override public void paintTitle(Graphics graphics) { if (Utils.isNotEmpty(getText())){ graphics.pushState(); Color bgColor = graphics.getBackgroundColor(); graphics.setBackgroundColor(ColorConstants.white); int titleHeight = FigureUtilities.getStringExtents(getText(), titleFont).height; Rectangle titleRect = getTextHolderRectangle(); Rectangle imRect = new Rectangle(titleRect.x + getMargin(), titleRect.y + getMargin(), titleHeight, titleHeight); graphics.fillArc(imRect, 0, 360); graphics.setBackgroundColor(bgColor); imRect.shrink(4, 4); graphics.fillArc(imRect, 0, 360); graphics.setBackgroundColor(ColorConstants.white); graphics.fillPolygon(new int[]{imRect.x + imRect.width / 6, imRect.y + imRect.width / 3, imRect.x + imRect.width - imRect.width/ 6, imRect.y + imRect.width / 3, imRect.x + imRect.width/ 2, imRect.y + imRect.width}); graphics.setBackgroundColor(ColorConstants.gray); graphics.drawLine(titleRect.x + 50, titleRect.y + titleHeight + getMargin() + 1, titleRect.right() - 50, titleRect.y + titleHeight + getMargin() + 1); graphics.popState(); titleRect.x += titleHeight + getMargin()*2; titleRect.width -= titleHeight + getMargin()*3; paintString(graphics, getText(), titleRect); } }
@Override protected void paintTitaniumFigure(Graphics graphics) { String time = getTime(); time_width = FigureUtilities .getStringExtents(time, graphics.getFont()).width; graphics.setForegroundColor(ColorConstants.white); this.paintString(graphics, time, getBounds()); this.paintRightImage(graphics); this.paintSignalImage(graphics); this.paintSignal3GImage(graphics); }
@Override protected void paintTitaniumFigure(Graphics graphics) { titleFont = createTitleFont(); graphics.pushState(); graphics.setFont(titleFont); paintTitle(graphics); graphics.popState(); paintLines(graphics, getLines(), getLinesHolderRectangle()); Rectangle expRect = getTextHolderRectangle(); if (explanation != null && explanation.length() > 0){ int titleHeight = getMargin()*2; if (getText() != null && getText().length() > 0){ titleHeight += FigureUtilities.getStringExtents(getText(), titleFont).height; } expRect.height -= titleHeight; expRect.y += titleHeight; paintString(graphics, explanation, expRect); } if (okButton.getText() != null){ graphics.setFont(okButton.getFont_()); Dimension p = FigureUtilities.getStringExtents(okButton.getText(), okButton.getFont_()); p.expand(20, 4); p.width = Math.min(p.width, expRect.width); p.height = 40; okButton.setBounds(new Rectangle(expRect.getBottomLeft().getTranslated( (expRect.width - p.width) / 2, -2 - p.height), p)); okButton.paint(graphics); } titleFont.dispose(); }
protected Rectangle getLinesHolderRectangle(){ Rectangle r = getClientArea(); if (useLocalCoordinates()){ r.setLocation(getBounds().getLocation()); } if (getText() != null && getText().length() > 0){ Dimension textSize = FigureUtilities.getStringExtents(getText(), titleFont); r.y += textSize.height + getMargin(); r.height -= textSize.height + getMargin(); } return r; }
public static void drawBadge(Graphics graphics, Rectangle r, String text){ if (Utils.isNotEmpty(text)){ graphics.setBackgroundColor(ColorConstants.white); Dimension textSize = FigureUtilities.getStringExtents(text, graphics.getFont()); int h = textSize.height; int w = Math.max(h, textSize.width + 8); int radius = Math.min(w, h); graphics.fillRoundRectangle(new Rectangle(r.right()-w-2, r.y+2, w, h), radius, radius); graphics.setBackgroundColor(ColorConstants.red); Rectangle textRect = new Rectangle(r.right()-w-1, r.y + 3,w-2, h-2); radius = Math.min(textRect.width, textRect.height); graphics.fillRoundRectangle(textRect, radius, radius); drawString(graphics, text, textRect); } }
public static void drawString(Graphics graphics, String text, Rectangle parentRect, Alignments hAlign, Alignments vAlign, int textMargin) { if (text != null && text.length() > 0){ graphics.pushState(); Dimension textSize = FigureUtilities.getStringExtents(text, graphics.getFont()); Point textLocation = getTextLocation(parentRect, textSize, hAlign, vAlign, textMargin); graphics.clipRect(parentRect); graphics.drawString(text, textLocation); graphics.popState(); } }
protected void paintLeftImage(Graphics graphics) { if (signalImage != null){ Rectangle dest = super.getTextHolderRectangle(); Dimension textSize = FigureUtilities.getStringExtents(CARRIER, graphics.getFont()); dest.translate(textSize.width + getMargin()*2, (dest.height - IMAGE_SIZE) / 2); dest.setSize(new Dimension(IMAGE_SIZE, IMAGE_SIZE)); graphics.drawImage(signalImage, new Rectangle(0, 0, signalImage.getImageData().width, signalImage.getImageData().height), dest); } }
public int getTitleHeight(){ if (getFont_() != null){ return FigureUtilities.getStringExtents("Some Text", getFont_()).height; } else { return FigureUtilities.getStringExtents("Some Text", Display.getCurrent().getSystemFont()).height; } }
public static List<String> wrap(String text, int width, Font font){ if (text == null) return Collections.emptyList(); text = text.trim(); List<String> lines = new ArrayList<String>(); if (text.length() != 0){ if (FigureUtilities.getStringExtents(text, font).width > width){ int i = text.length() - 2; //find the maximum string length for (;FigureUtilities.getStringExtents(text.substring(0, i), font).width > width && i > 0;i--){ i--; } int j = i + 1;//include previous char to delimiter test while (delimiters.indexOf(text.charAt(j)) < 0 && j > 0){j--;} if (j == 0){//no delimiters are found lines.add(text.substring(0, i)); lines.addAll(wrap(text.substring(i), width, font)); } else {//delimiter at position j //include delimiter as it can be not a whitespace lines.add(text.substring(0, j + 1).trim()); lines.addAll(wrap(text.substring(j + 1), width, font)); } } else { lines.add(text); } } return lines; }
/** * Creates the figure used for feedback. * * @return the new feedback figure */ protected IFigure createDragSourceFeedbackFigure() { // Use a ghost rectangle for feedback RectangleFigure r = new RectangleFigure(); FigureUtilities.makeGhostShape(r); r.setLineStyle(Graphics.LINE_DOT); r.setForegroundColor(ColorConstants.white); r.setBounds(getInitialFeedbackBounds()); addFeedback(r); return r; }
/** * Draw the X tick. * * @param grahics * the graphics context */ private void drawXTick(Graphics grahics) { // draw tick labels grahics.setFont(scale.getFont()); for (int i = 0; i < tickLabelPositions.size(); i++) { if (tickVisibilities.get(i) == true) { String text = tickLabels.get(i); int fontWidth = FigureUtilities.getTextExtents(text, getFont()).width; int x = (int) Math.ceil(tickLabelPositions.get(i) - fontWidth / 2.0);// + offset); grahics.drawText(text, x, 0); } } }
/** * Gets max length of tick label. */ private void updateTickLabelMaxLength() { int maxLength = 0; for (int i = 0; i < labels.length; i++) { Dimension p = FigureUtilities.getTextExtents(labels[i], scale.getFont()); if (p.width > maxLength) { maxLength = p.width; } } tickLabelMaxLength = maxLength; }
private void calcMargin() { if(isHorizontal()) { margin = (int) Math.ceil(Math.max(FigureUtilities.getTextExtents( format(getRange().getLower(), true),getFont()).width, FigureUtilities.getTextExtents(format(getRange().getUpper(), true), getFont()).width)/2.0); }else margin = (int) Math.ceil(Math.max(FigureUtilities.getTextExtents( format(getRange().getLower(), true), getFont()).height, FigureUtilities.getTextExtents(format(getRange().getUpper(), true), getFont()).height)/2.0); }
@Override protected void fillShape(Graphics graphics) { if(!((XYGraph)getParent()).isTransparent()) super.fillShape(graphics); int hPos = bounds.x +INNER_GAP; int vPos = bounds.y - INNER_GAP; // up little int i = 0; // Added by scouter.project positionList.clear(); for(Trace trace : traceList){ int hwidth = OUT_GAP + ICON_WIDTH + INNER_GAP + + FigureUtilities.getTextExtents(trace.getName(), getFont()).width; int hEnd = hPos + hwidth; if(hEnd > (bounds.x + bounds.width) && i>0){ hPos= bounds.x + INNER_GAP; vPos += ICON_WIDTH + INNER_GAP; hEnd = hPos + hwidth; } // graphics.setForegroundColor(trace.getYAxis().getForegroundColor()); // Rectangle rect = new Rectangle(hPos, vPos-INNER_GAP/2, hwidth - OUT_GAP,ICON_WIDTH-INNER_GAP); // graphics.fillRectangle(rect); // graphics.drawRectangle(rect); drawTraceLagend(trace, graphics, hPos, vPos); hPos = hEnd; i++; } }
@Override protected Image createInternalVerticalTextImage(String text, Font font, RGB color, boolean upToDown) { final Dimension titleSize = FigureUtilities.getTextExtents(text, font); final int w = titleSize.height; final int h = titleSize.width + 1; Image image = new Image(Display.getCurrent(), w, h); final GC gc = new GC(image); final Color titleColor = new Color(Display.getCurrent(), color); RGB transparentRGB = new RGB(240, 240, 240); gc.setBackground(XYGraphMediaFactory.getInstance().getColor( transparentRGB)); gc.fillRectangle(image.getBounds()); gc.setForeground(titleColor); gc.setFont(font); final Transform tr = new Transform(Display.getCurrent()); if (!upToDown) { tr.translate(0, h); tr.rotate(-90); gc.setTransform(tr); } else { tr.translate(w, 0); tr.rotate(90); gc.setTransform(tr); } gc.drawText(text, 0, 0); tr.dispose(); gc.dispose(); final ImageData imageData = image.getImageData(); image.dispose(); titleColor.dispose(); imageData.transparentPixel = imageData.palette.getPixel(transparentRGB); image = new Image(Display.getCurrent(), imageData); return image; }