Java 类org.eclipse.jface.resource.ResourceManager 实例源码

项目:neoscada    文件:YAxisDynamicRenderer.java   
@Override
public Rectangle resize ( final ResourceManager resourceManager, final Rectangle clientRectangle )
{
    final int width = this.width >= 0 ? this.width : calcWidth ( resourceManager, clientRectangle.height );

    if ( this.left )
    {
        this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y, width, clientRectangle.height );
        return new Rectangle ( clientRectangle.x + width, clientRectangle.y, clientRectangle.width - width, clientRectangle.height );
    }
    else
    {
        this.rect = new Rectangle ( clientRectangle.x + clientRectangle.width - width, clientRectangle.y, width, clientRectangle.height );
        return new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width - width, clientRectangle.height );
    }
}
项目:neoscada    文件:TitleRenderer.java   
@Override
public Rectangle resize ( final ResourceManager resourceManager, final Rectangle clientRectangle )
{
    if ( this.title == null || this.title.isEmpty () )
    {
        return null;
    }

    final GC gc = new GC ( resourceManager.getDevice () );
    gc.setFont ( createFont ( resourceManager ) );

    try
    {
        final Point size = gc.textExtent ( this.title );
        this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, size.y + this.padding * 2 );
        return new Rectangle ( clientRectangle.x, this.rect.y + this.rect.height, clientRectangle.width, clientRectangle.height - this.rect.height );
    }
    finally
    {
        gc.dispose ();
    }
}
项目:neoscada    文件:TitleRenderer.java   
private Font createFont ( final ResourceManager resourceManager )
{
    final Font defaultFont = resourceManager.getDevice ().getSystemFont ();

    if ( defaultFont == null )
    {
        return null;
    }

    final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
    if ( fd == null )
    {
        return null;
    }

    for ( final FontData f : fd )
    {
        if ( this.fontSize > 0 )
        {
            f.setHeight ( this.fontSize );
        }
    }
    return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
项目:neoscada    文件:XAxisDynamicRenderer.java   
@Override
public Rectangle resize ( final ResourceManager resourceManager, final Rectangle clientRectangle )
{
    final int height = this.height >= 0 ? this.height : calcHeight ( resourceManager );

    if ( this.bottom )
    {
        this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y + clientRectangle.height - height, clientRectangle.width, height );
        return new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, clientRectangle.height - height );
    }
    else
    {
        this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, height );
        return new Rectangle ( clientRectangle.x, clientRectangle.y + height, clientRectangle.width, clientRectangle.height - height );
    }
}
项目:neoscada    文件:InputManager.java   
public InputManager ( final DataBindingContext dbc, final ChartViewer viewer, final ResourceManager resourceManager, final AxisLocator<XAxis, XAxisViewer> xLocator, final AxisLocator<YAxis, YAxisViewer> yLocator )
{
    this.list = new WritableList ( dbc.getValidationRealm () );

    this.dbc = dbc;
    this.viewer = viewer;
    this.resourceManager = resourceManager;

    this.xLocator = xLocator;
    this.yLocator = yLocator;

    this.list.addListChangeListener ( this.listener = new IListChangeListener () {

        @Override
        public void handleListChange ( final ListChangeEvent event )
        {
            handleListeChange ( event.diff );
        }
    } );
}
项目:neoscada    文件:ScriptInput.java   
public ScriptInput ( final ChartViewer viewer, final Realm realm, final ResourceManager resourceManager, final XAxis xAxis, final YAxis yAxis )
{
    super ( resourceManager );

    this.viewer = viewer;

    this.renderer = new StepRenderer ( viewer.getChartRenderer (), this.dataSeries = new AsyncFunctionSeriesData ( realm, xAxis, yAxis, 0 ) {

        @Override
        protected Double eval ( final long timestamp )
        {
            return handleEval ( timestamp );
        }
    } );
    viewer.getChartRenderer ().addRenderer ( this.renderer );

    attachHover ( viewer, xAxis );
}
项目:neoscada    文件:TextController.java   
public TextController ( final FigureCanvas canvas, final SymbolController controller, final Text element, final ResourceManager manager )
{
    super ( controller, manager );
    this.canvas = canvas;
    this.figure = new Label ( element.getText ()) {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        protected void paintFigure ( final Graphics graphics )
        {
            final Double alpha = getAlpha ();
            if ( alpha != null )
            {
                graphics.setAlpha ( (int) ( Math.max ( 0.0, Math.min ( 1.0, alpha ) ) * 255.0 ) );
            }
            super.paintFigure ( graphics );
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ( );
        }
    };
    controller.addElement ( element, this );

    applyCommon ( element );
}
项目:neoscada    文件:ArcController.java   
public ArcController ( final SymbolController controller, final Arc element, final ResourceManager manager )
{
    super ( controller, manager );

    this.figure = new ArcShape () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };

    this.figure.setArc ( element.getStart (), element.getLength () );

    controller.addElement ( element, this );

    applyCommon ( element );
}
项目:triquetrum    文件:TextDrawingStrategy.java   
@Override
public void draw(TextAttribute textAttr, Graphics graphics, ResourceManager resourceManager) {
  Color fgColor = graphics.getForegroundColor();
  java.awt.Color color = textAttr.textColor.asColor();
  if (color != null) {
    Color rgb = resourceManager.createColor(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
    graphics.setForegroundColor(rgb);
  }

  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));
    graphics.setFont(f);

    Point tlp = getTopLeftLocation(textAttr);
    graphics.drawText(text, tlp);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading properties for " + textAttr.getFullName(), e);
  }
  graphics.setForegroundColor(fgColor);
}
项目:triquetrum    文件:TextDrawingStrategy.java   
@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);
  }
}
项目:codeexamples-eclipse    文件:TableViewerFontSize.java   
@PostConstruct
public void postConstruct(Composite parent) {

    ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);

    TreeViewer viewer = new TreeViewer(parent);
    viewer.setContentProvider(new TreeContentProvider());
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    viewer.getTree().setFont(resourceManager.createFont(FontDescriptor.createFrom("Arial", 32, SWT.ITALIC)));

    TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, SWT.NONE);
    viewerColumn.getColumn().setWidth(300);
    viewerColumn.getColumn().setText("Names");
    viewerColumn.setLabelProvider(new ColumnLabelProvider());

    viewer.setInput(new String[] { "Simon Scholz", "Lars Vogel", "Dirk Fauth", "Wim Jongman", "Tom Schindl" });

    GridLayoutFactory.fillDefaults().generateLayout(parent);
}
项目:neoscada    文件:XAxisDynamicRenderer.java   
private int calcHeight ( final ResourceManager resourceManager )
{
    if ( this.axis == null )
    {
        return 0;
    }

    final GC gc = new GC ( resourceManager.getDevice () );
    try
    {
        gc.setFont ( makeFont ( resourceManager ) );

        final DateFormat format = makeFormat ( this.axis.getMax () - this.axis.getMin () );

        final Point markerSize = getExtent ( gc, format.format ( new Date () ) );
        final Point labelSize = getExtent ( gc, this.axis.getLabel () );

        int height = markerSize.y + labelSize.y + this.textPadding * 2 + this.markerSize;

        if ( labelSize.y > 0 )
        {
            height += this.textPadding;
        }

        return height;
    }
    finally
    {
        gc.dispose ();
    }
}
项目:neoscada    文件:VisualInterfaceFactory.java   
@Override
public ViewInstance createViewInstance ( final ViewManager viewManager, final ViewManagerContext viewManagerContext, final ViewInstanceDescriptor descriptor, final Composite viewHolder, final ResourceManager manager, final IWorkbenchPartSite site )
{
    final VisualInterfaceViewInstance instance = new VisualInterfaceViewInstance ( viewManager, viewManagerContext, viewHolder, descriptor, site.getService ( IEvaluationService.class ) );
    instance.init ();
    return instance;
}
项目:neoscada    文件:AbstractInputViewer.java   
public AbstractInputViewer ( final DataBindingContext dbc, final DataSeries element, final ChartViewer viewer, final ResourceManager resourceManager, final AxisLocator<XAxis, XAxisViewer> xLocator, final AxisLocator<YAxis, YAxisViewer> yLocator )
{
    this.element = element;
    this.viewer = viewer;
    this.dbc = dbc;

    this.resourceManager = new LocalResourceManager ( resourceManager );

    this.xLocator = xLocator;
    this.yLocator = yLocator;

    addBinding ( dbc.bindValue ( PojoObservables.observeValue ( this, "x" ), EMFObservables.observeValue ( element, ChartPackage.Literals.DATA_SERIES__X ) ) ); //$NON-NLS-1$
    addBinding ( dbc.bindValue ( PojoObservables.observeValue ( this, "y" ), EMFObservables.observeValue ( element, ChartPackage.Literals.DATA_SERIES__Y ) ) ); //$NON-NLS-1$
}
项目:neoscada    文件:DataItemSeriesViewer.java   
public DataItemSeriesViewer ( final DataBindingContext dbc, final DataItemSeries element, final ChartViewer viewer, final ResourceManager resourceManager, final AxisLocator<XAxis, XAxisViewer> xLocator, final AxisLocator<YAxis, YAxisViewer> yLocator )
{
    super ( dbc, element, viewer, resourceManager, xLocator, yLocator );

    this.inputObservable = BeansObservables.observeValue ( this, PROP_INPUT );
    this.linePropertiesObservable = EMFObservables.observeValue ( element, ChartPackage.Literals.DATA_ITEM_SERIES__LINE_PROPERTIES );

    addBindings ( LinePropertiesBinder.bind ( dbc, this.inputObservable, this.linePropertiesObservable ) );

    setInputObserable ( this.inputObservable );
}
项目:neoscada    文件:ScriptSeriesViewer.java   
public ScriptSeriesViewer ( final DataBindingContext dbc, final ScriptSeries element, final ChartViewer viewer, final ResourceManager resourceManager, final AxisLocator<XAxis, XAxisViewer> xLocator, final AxisLocator<YAxis, YAxisViewer> yLocator )
{
    super ( dbc, element, viewer, resourceManager, xLocator, yLocator );

    this.inputObservable = BeansObservables.observeValue ( this, PROP_INPUT );
    this.linePropertiesObservable = EMFObservables.observeValue ( element, ChartPackage.Literals.SCRIPT_SERIES__LINE_PROPERTIES );

    addBinding ( dbc.bindValue ( PojoObservables.observeDetailValue ( this.inputObservable, "script", null ), EMFObservables.observeValue ( element, ChartPackage.Literals.SCRIPT_SERIES__SCRIPT ) ) ); //$NON-NLS-1$
    addBindings ( LinePropertiesBinder.bind ( dbc, this.inputObservable, this.linePropertiesObservable ) );

    setInputObserable ( this.inputObservable );
}
项目:neoscada    文件:ColorUpdater.java   
public ColorUpdater ( final String name, final ResourceManager manager, final ColorDescriptor defaultColor )
{
    this.name = name;
    this.manager = manager;
    this.defaultColor = defaultColor;
    JFaceResources.getColorRegistry ().addListener ( this );
    refresh ();
}
项目:neoscada    文件:ChartView.java   
public ChartView ( final ViewManagerContext viewManagerContext, final ResourceManager manager, final ViewInstanceDescriptor descriptor, final Composite viewHolder, final IEvaluationService evaluationService, final boolean showSelector )
{
    super ( viewManagerContext, descriptor, evaluationService );
    this.showSelector = showSelector;
    this.viewHolder = viewHolder;
    this.viewManagerContext = viewManagerContext;
}
项目:neoscada    文件:ChartViewFactory.java   
@Override
public ViewInstance createViewInstance ( final ViewManager viewManager, final ViewManagerContext viewManagerContext, final ViewInstanceDescriptor descriptor, final Composite viewHolder, final ResourceManager manager, final IWorkbenchPartSite site )
{
    final ChartView view = new ChartView ( viewManagerContext, manager, descriptor, viewHolder, (IEvaluationService)site.getService ( IEvaluationService.class ), true );
    view.init ();
    return view;
}
项目:neoscada    文件:ViewElementFactory.java   
@Override
public Controller create ( final SymbolController controller, final Primitive element, final SymbolLoader symbolLoader, final ResourceManager manager, final BasicViewElementFactory basicViewElementFactory, final FactoryContext context )
{
    try
    {
        final ChartView view = (ChartView)element;
        return new ChartController ( controller, manager, view, symbolLoader, context );
    }
    catch ( final Exception e )
    {
        return Helper.createErrorController ( e );
    }
}
项目:neoscada    文件:ChartController.java   
public ChartController ( final SymbolController symbolController, final ResourceManager resourceManager, final ChartView view, final SymbolLoader symbolLoader, final FactoryContext context )
{
    super ( symbolController, resourceManager );

    this.context = context;

    this.symbolLoader = symbolLoader;

    this.wrapperFigure = new Figure () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };

    this.wrapperFigure.setOpaque ( false );
    this.figure = new ChartFigure ( Display.getCurrent (), resourceManager );

    this.wrapperFigure.setLayoutManager ( new StackLayout () );
    this.wrapperFigure.add ( this.figure );
    this.errorFigure = new ErrorFigure ();

    symbolController.addElement ( view, this );

    applyCommon ( view );
}
项目:neoscada    文件:FigureRenderer.java   
public FigureRenderer ( final ChartFigure chartFigure, final ResourceManager resourceManager )
{
    super ( resourceManager );

    this.realm = new DisplayRealm ( Display.getCurrent () );

    this.chartFigure = chartFigure;
    this.figureListener = new FigureListenerImpl ();
    this.chartFigure.addFigureListener ( this.figureListener );
}
项目:neoscada    文件:LineController.java   
public LineController ( final SymbolController controller, final Line element, final ResourceManager manager )
{
    super ( controller, manager );

    this.figure = new PolylineShape () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };

    final PointList points = new PointList ();
    for ( final Position pos : element.getPoints () )
    {
        final Point p = new PrecisionPoint ( pos.getX (), pos.getY () );
        points.addPoint ( p );
    }
    setPoints ( points );

    controller.addElement ( element, this );

    applyCommon ( element );
}
项目:neoscada    文件:RoundedRectangleController.java   
public RoundedRectangleController ( final SymbolController controller, final RoundedRectangle element, final ResourceManager manager )
{
    super ( controller, manager );

    this.figure = new org.eclipse.draw2d.RoundedRectangle () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };

    if ( element.getCorner () != null )
    {
        setCorner ( Double.valueOf ( Math.round ( element.getCorner ().getWidth () ) ).intValue (), Double.valueOf ( Math.round ( element.getCorner ().getWidth () ) ).intValue () );
    }
    else
    {
        setCorner ( 0, 0 );
    }

    controller.addElement ( element, this );

    applyCommon ( element );
}
项目:neoscada    文件:EllipseController.java   
public EllipseController ( final SymbolController controller, final org.eclipse.scada.vi.model.Ellipse element, final ResourceManager manager )
{
    super ( controller, manager );
    final PrecisionRectangle rect = new PrecisionRectangle ();
    if ( element.getSize () != null )
    {
        rect.setPreciseSize ( element.getSize ().getWidth (), element.getSize ().getHeight () );
    }
    this.figure = new Ellipse () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };
    this.figure.setBounds ( rect );

    controller.addElement ( element, this );

    applyCommon ( element );
}
项目:neoscada    文件:PolygonController.java   
public PolygonController ( final SymbolController controller, final Polygon element, final ResourceManager manager )
{
    super ( controller, manager );

    this.figure = new PolygonShape () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };

    final PointList points = new PointList ();
    for ( final Position pos : element.getPoints () )
    {
        final Point p = new PrecisionPoint ( pos.getX (), pos.getY () );
        points.addPoint ( p );
    }
    setPoints ( points );

    controller.addElement ( element, this );

    applyCommon ( element );
}
项目:neoscada    文件:RectangleController.java   
public RectangleController ( final SymbolController controller, final Rectangle element, final ResourceManager manager )
{
    super ( controller, manager );
    final PrecisionRectangle rect = new PrecisionRectangle ();
    if ( element.getSize () != null )
    {
        rect.setPreciseSize ( element.getSize ().getWidth (), element.getSize ().getHeight () );
    }
    this.figure = new RectangleFigureExtension ( this );
    this.figure.setBounds ( rect );

    controller.addElement ( element, this );

    applyCommon ( element );
}
项目:neoscada    文件:ImageController.java   
public ImageController ( final FigureCanvas canvas, final SymbolController controller, final Image element, final SymbolLoader symbolLoader, final ResourceManager manager, final FactoryContext factoryContext )
{
    super ( controller, manager );
    this.factoryContext = factoryContext;

    this.symbolLoader = symbolLoader;

    this.figure = new Label () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };
    controller.addElement ( element, this );

    applyCommon ( element );
    setImage ( element.getUri () );
}
项目:neoscada    文件:FigureContainerController.java   
public FigureContainerController ( final SymbolController controller, final FigureContainer element, final ResourceManager manager, final BasicViewElementFactory viewElementFactory ) throws Exception
{
    super ( controller, manager );

    this.figure = new Figure () {
        @Override
        public void addNotify ()
        {
            super.addNotify ();
            start ();
        }

        @Override
        public void removeNotify ()
        {
            stop ();
            super.removeNotify ();
        }
    };

    if ( element.getSize () != null )
    {
        final PrecisionRectangle rect = new PrecisionRectangle ();
        rect.setPreciseSize ( element.getSize ().getWidth (), element.getSize ().getHeight () );
        this.figure.setBounds ( rect );
    }

    controller.addElement ( element, this );

    this.figure.setLayoutManager ( new StackLayout () );
    this.figure.add ( viewElementFactory.create ( controller, element.getContent () ).getFigure () );

    applyCommon ( element );
}
项目:neoscada    文件:BasicViewElementFactory.java   
public BasicViewElementFactory ( final FigureCanvas canvas, final ResourceManager manager, final SymbolLoader symbolLoader, final FactoryContext factoryContext )
{
    this.manager = manager;
    this.canvas = canvas;
    this.symbolLoader = symbolLoader;
    this.symbolCache = new HashMap<URI, XMISymbolLoader> ();

    this.factoryContext = factoryContext == null ? FactoryContext.DEFAULT : factoryContext;
}
项目:neoscada    文件:BasicViewElementFactory.java   
public BasicViewElementFactory ( final FigureCanvas canvas, final ResourceManager manager, final SymbolLoader symbolLoader, final FactoryContext factoryContext, final Map<URI, XMISymbolLoader> symbolCache )
{
    this.manager = manager;
    this.canvas = canvas;
    this.symbolLoader = symbolLoader;
    this.symbolCache = symbolCache;

    this.factoryContext = factoryContext == null ? FactoryContext.DEFAULT : factoryContext;
}
项目:gw4e.project    文件:ModelSearchResultPage.java   
private boolean isModelFile (IFile file) {
    String extension = org.gw4e.eclipse.facade.ResourceManager.getExtensionFile(file);
    if (extension == null)
        return false;
    boolean isModel = PreferenceManager.isConvertable(extension);
    return isModel;
}
项目:yamcs-studio    文件:ThemeColorBlock.java   
public ThemeColorBlock(StyleDefinition def, Device device, ResourceManager resourceManager) {
    this.def = def;
    for (ThemeColor color : def.getColors()) {
        RGB rgb = color.getRGB();
        if (!colorMap.containsKey(rgb)) {
            colorMap.put(rgb, resourceManager.createColor(rgb));
        }
    }

    upImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ThemeColorBlock.class, "icons/up.gif"));
    downImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ThemeColorBlock.class, "icons/down.gif"));
}
项目:yamcs-studio    文件:LoginDialog.java   
@Override
public void create() {
    super.create();
    setTitle("Connect to " + nvl(conf.getName(), conf.getPrimaryConnectionString()));
    setMessage("Please provide your credentials");
    ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), getShell());
    Image titleImage = resourceManager
            .createImage(RCPUtils.getImageDescriptor(LoginDialog.class, "icons/yamcs_banner.png"));
    setTitleImage(titleImage);
}
项目:triquetrum    文件:FilledShapeDrawingStrategy.java   
/**
 * 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);
  }
}
项目:triquetrum    文件:FilledShapeDrawingStrategy.java   
/**
 * @return the shape's dimension based oon the width and height of the shapeAttribute
 */
@Override
protected final Dimension getDimension(A shapeAttribute, ResourceManager resourceManager) {
  try {
    int width = (int) ((DoubleToken) shapeAttribute.width.getToken()).doubleValue();
    int height = (int) ((DoubleToken) shapeAttribute.height.getToken()).doubleValue();
    return new Dimension(width, height);
  } catch (IllegalActionException e) {
    getLogger().error("Error reading dimensions for " + shapeAttribute.getFullName(), e);
    return new Dimension(0, 0);
  }
}
项目:triquetrum    文件:ArrowDrawingStrategy.java   
@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);
}
项目:triquetrum    文件:ArrowDrawingStrategy.java   
@Override
protected Dimension getDimension(ArrowAttribute arrowAttr, ResourceManager resourceManager) {
  try {
    int length = (int) ((DoubleToken) arrowAttr.arrowLength.getToken()).doubleValue();
    int width = (int) ((DoubleToken) arrowAttr.arrowWidth.getToken()).doubleValue();
    return new Dimension(length, width);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading dimensions for " + arrowAttr.getFullName(), e);
    return new Dimension(0, 0);
  }
}
项目:triquetrum    文件:ImageDrawingStrategy.java   
@Override
public void draw(ImageAttribute imageAttr, Graphics graphics, ResourceManager resourceManager) {
  try {
    Image img = resourceManager.createImage(buildImageDescriptor(imageAttr));
    Point tlp = getTopLeftLocation(imageAttr);
    graphics.drawImage(img, tlp);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading image for " + imageAttr.getFullName(), e);
  }
}
项目:triquetrum    文件:ImageDrawingStrategy.java   
@Override
protected Dimension getDimension(ImageAttribute imageAttr, ResourceManager resourceManager) {
  try {
    Image img = resourceManager.createImage(buildImageDescriptor(imageAttr));
    return new Dimension(img.getBounds().width, img.getBounds().height);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading dimensions for " + imageAttr.getFullName(), e);
    return new Dimension(0, 0);
  }
}