Java 类org.eclipse.swt.widgets.Canvas 实例源码

项目:AppleCommander    文件:DiskMapTab.java   
/**
 * Handle paint requests for vertical ruler.
 */
protected void paintVerticalRuler(PaintEvent event) {
    // FIXME - not i18n safe!!
    String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
    if (disk.getBitmapLabels().length == 2) {
        label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
    }
    StringBuffer buf = new StringBuffer();
    for (int i=0; i<label.length(); i++) {
        if (i>0) buf.append("\n"); //$NON-NLS-1$
        buf.append(label.charAt(i));
    }
    label = buf.toString();
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();
    event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
    Point size = event.gc.textExtent(label);
    event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
项目:AppleCommander    文件:DiskMapTab.java   
/**
 * Paint a block map.
 */ 
private void paintBlockMap(PaintEvent event) {
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();

    double blocks = disk.getBitmapLength();
    double width = area.width;
    double height = area.height;
    double factor = Math.sqrt(blocks / (width * height));
    int xdim = (int) (width * factor + 0.5);
    int ydim = (int) (height * factor + 0.5);
    if (xdim * ydim < blocks) {
        xdim++;
    }
    if (xdim * ydim < blocks) {
        ydim++;
    }

    paintDiskMap(xdim, ydim, event);
}
项目:gw4e.project    文件:GW4EPreferencePage.java   
protected Control createContents(Composite parent) {
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.numColumns = 1;
    parent.setLayout(gridLayout);

    String[] values = PreferenceManager.getAuthorizedFolderForGraphDefinition();
    String[] propertyNames = new String[] { PreferenceManager.AUTHORIZED_FOLDERS_FOR_GRAPH_DEFINITION };
    authorizedFolders = new CustomListWithButtons(parent, SWT.NONE, true,
            new StringCustomListModel(MessageUtil.getString("authorizedfolderforgraphmodel"), values));
    authorizedFolders.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    authorizedFolders.setPropertyNames(propertyNames);

    values = PreferenceManager.getGraphWalkerJavaLibName();
    propertyNames = new String[] { PreferenceManager.GRAPHWALKER_JAVALIBRARIES };
    gw4eLibraries = new CustomListWithButtons(parent, SWT.NONE, true,
            new StringCustomListModel(MessageUtil.getString("graphwalkerlibraries"), values));
    gw4eLibraries.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    gw4eLibraries.setPropertyNames(propertyNames);

    return new Canvas(parent, 0);
}
项目:applecommander    文件:DiskMapTab.java   
/**
 * Handle paint requests for vertical ruler.
 */
protected void paintVerticalRuler(PaintEvent event) {
    // FIXME - not i18n safe!!
    String label = (disk.getBitmapLabels()[0] + "s").toUpperCase(); //$NON-NLS-1$
    if (disk.getBitmapLabels().length == 2) {
        label = (disk.getBitmapLabels()[1] + "s").toUpperCase(); //$NON-NLS-1$
    }
    StringBuffer buf = new StringBuffer();
    for (int i=0; i<label.length(); i++) {
        if (i>0) buf.append("\n"); //$NON-NLS-1$
        buf.append(label.charAt(i));
    }
    label = buf.toString();
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();
    event.gc.drawLine(area.x + area.width/2, area.y, area.x + area.width/2, area.y + area.height);
    Point size = event.gc.textExtent(label);
    event.gc.drawText(label, area.x + area.width/2 - size.x/2, area.y + area.height/2 - size.y/2);
}
项目:applecommander    文件:DiskMapTab.java   
/**
 * Paint a block map.
 */ 
private void paintBlockMap(PaintEvent event) {
    Canvas canvas = (Canvas) event.widget;
    Rectangle area = canvas.getClientArea();

    double blocks = disk.getBitmapLength();
    double width = area.width;
    double height = area.height;
    double factor = Math.sqrt(blocks / (width * height));
    int xdim = (int) (width * factor + 0.5);
    int ydim = (int) (height * factor + 0.5);
    if (xdim * ydim < blocks) {
        xdim++;
    }
    if (xdim * ydim < blocks) {
        ydim++;
    }

    paintDiskMap(xdim, ydim, event);
}
项目:ermasterr    文件:ERDiagramOutlinePage.java   
/**
 * {@inheritDoc}
 */
@Override
public void createControl(final Composite parent) {
    sash = new SashForm(parent, SWT.VERTICAL);

    // コンストラクタで指定したビューワの作成
    viewer.createControl(sash);

    // EditPartFactory の設定
    final ERDiagramOutlineEditPartFactory editPartFactory = new ERDiagramOutlineEditPartFactory();
    viewer.setEditPartFactory(editPartFactory);

    // グラフィカル・エディタのルート・モデルをツリー・ビューワにも設定
    viewer.setContents(diagram);

    final Canvas canvas = new Canvas(sash, SWT.BORDER);
    // サムネイル・フィギュアを配置する為の LightweightSystem
    lws = new LightweightSystem(canvas);

    resetView(registry);

    final AbstractTransferDragSourceListener dragSourceListener = new ERDiagramTransferDragSourceListener(viewer, TemplateTransfer.getInstance());
    viewer.addDragSourceListener(dragSourceListener);

    diagram.refreshOutline();
}
项目:ether    文件:PlotWindow.java   
public PlotWindow(final AbstractRenderCommand<?> cmd) {
    this.cmd = cmd;
    Platform.get().runOnMainThread(new Runnable() {
        @Override
        public void run() {
            shell = new Shell(Display.getDefault());
            shell.setText("Plot");
            shell.setLayout(new FillLayout());
            canvasUI = new Canvas(shell, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND);
            canvasUI.addPaintListener(PlotWindow.this);
            canvasUI.addMouseListener(PlotWindow.this);
            canvasUI.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            shell.pack();
            shell.setSize(800, shell.getSize().y);
            shell.setVisible(true);
            shell.setActive();
            new Repeating(500, 20, canvasUI, canvasUI::redraw);
        }
    });
}
项目:typescript.java    文件:IndentFoldingStrategy.java   
/**
 * Does not paint hidden annotations. Annotations are hidden when they
 * only span one line.
 * 
 * @see ProjectionAnnotation#paint(org.eclipse.swt.graphics.GC,
 *      org.eclipse.swt.widgets.Canvas,
 *      org.eclipse.swt.graphics.Rectangle)
 */
@Override
public void paint(GC gc, Canvas canvas, Rectangle rectangle) {
    /* workaround for BUG85874 */
    /*
     * only need to check annotations that are expanded because hidden
     * annotations should never have been given the chance to collapse.
     */
    if (!isCollapsed()) {
        // working with rectangle, so line height
        FontMetrics metrics = gc.getFontMetrics();
        if (metrics != null) {
            // do not draw annotations that only span one line and
            // mark them as not visible
            if ((rectangle.height / metrics.getHeight()) <= 1) {
                visible = false;
                return;
            }
        }
    }
    visible = true;
    super.paint(gc, canvas, rectangle);
}
项目:triquetrum    文件:DiagramEditorOutlinePage.java   
/**
 * Creates the Control of this outline page. By default this is a PageBook, which can toggle between a hierarchical Outline and a graphical Thumbnail.
 *
 * @param parent
 *          the parent
 * @see org.eclipse.gef.ui.parts.ContentOutlinePage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
  _pageBook = new PageBook(parent, SWT.NONE);
  _outline = getViewer().createControl(_pageBook);
  _overview = new Canvas(_pageBook, SWT.NONE);
  _pageBook.showPage(_outline);
  createOutlineViewer();

  // register listeners
  _selectionSynchronizer.addViewer(getViewer());
  if (_diagramEditor.getWorkbenchPart() != null) {
    _diagramEditor.getWorkbenchPart().addPropertyListener(this);
  }

  initContents();
}
项目:eavp    文件:CSVPlotEditor.java   
/**
 * This operation sets up the Composite that contains the VisIt canvas and
 * create the VisIt widget.
 * 
 * @param parent
 *            The parent Composite to create the Control in.
 */
@Override
public void createPartControl(Composite parent) {

    // Create a top level composite to hold the canvas or text
    vizComposite = new Composite(parent, SWT.NONE);
    vizComposite.setLayout(new GridLayout(1, true));

    // Set up the canvas where the graph is displayed
    plotCanvas = new Canvas(vizComposite, SWT.BORDER);
    plotCanvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // MAGIC
    lws = new LightweightSystem(plotCanvas);

    return;
}
项目:SMVHunter    文件:PixelPerfect.java   
public PixelPerfect(Composite parent) {
    super(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    mCanvas = new Canvas(this, SWT.NONE);
    setContent(mCanvas);
    setExpandHorizontal(true);
    setExpandVertical(true);
    mModel = PixelPerfectModel.getModel();
    mModel.addImageChangeListener(this);

    mCanvas.addPaintListener(mPaintListener);
    mCanvas.addMouseListener(mMouseListener);
    mCanvas.addMouseMoveListener(mMouseMoveListener);
    mCanvas.addKeyListener(mKeyListener);

    addDisposeListener(mDisposeListener);

    mCrosshairColor = new Color(Display.getDefault(), new RGB(0, 255, 255));
    mBorderColor = new Color(Display.getDefault(), new RGB(255, 0, 0));
    mMarginColor = new Color(Display.getDefault(), new RGB(0, 255, 0));
    mPaddingColor = new Color(Display.getDefault(), new RGB(0, 0, 255));

    imageLoaded();
}
项目:pentaho-pdi-dataset    文件:ShowUnitTestMenuExtensionPoint.java   
/** Find the canvas of TransGraph.  For some reason it's not exposed.
 * 
 * @param transGraph
 * @return Canvas of null if it can't be found.
 */
private Canvas findCanvas(Composite composite) {
  for (Control child : composite.getChildren()) {
    if (child instanceof Canvas) {
      return (Canvas) child;
    }
    if (child instanceof Composite) {
      Canvas look = findCanvas((Composite) child);
      if (look!=null) {
        return look;
      }
    }
  }

  return null;
}
项目:scouter    文件:ActiveSpeedCommonView.java   
public void createPartControl(Composite parent) {
    setTitleImage(Images.TYPE_ACTSPEED);
    canvas = new Canvas(parent, SWT.DOUBLE_BUFFERED);
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            try {
                area = canvas.getClientArea();
                drawCanvasImage(e.gc);
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    });

    window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
项目:lwjgl3-swt    文件:PlatformWin32GLCanvas.java   
public long create(GLCanvas canvas, GLData attribs, GLData effective) {
    Canvas dummycanvas = new Canvas(canvas.getParent(), checkStyle(canvas.getParent(), canvas.getStyle()));
    long context = 0L;
    MemoryStack stack = MemoryStack.stackGet(); int ptr = stack.getPointer();
    try {
        context = create(canvas.handle, dummycanvas.handle, attribs, effective);
    } catch (SWTException e) {
        stack.setPointer(ptr);
        SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH, e);
    }
    final long finalContext = context;
    dummycanvas.dispose();
    Listener listener = new Listener() {
        public void handleEvent(Event event) {
            switch (event.type) {
            case SWT.Dispose:
                deleteContext(finalContext);
                break;
            }
        }
    };
    canvas.addListener(SWT.Dispose, listener);
    return context;
}
项目:org.csstudio.display.builder    文件:LEDRepresentation.java   
@Override
protected Canvas createSWTControl(final Composite parent) throws Exception
{
    createColors();

    // Unfortunately, the canvas is not transparent..
    final Canvas canvas = new Canvas(parent, SWT.NO_FOCUS | SWT.NO_BACKGROUND | SWT.TRANSPARENT);
    canvas.addPaintListener(this::doPaint);

    canvas.addDisposeListener((e) ->
    {
        for (final Color color : colors)
            color.dispose();
    });
    return canvas;
}
项目:jdepend4eclipse    文件:MetricsView.java   
/**
 * This is a callback that will allow us
 * to create the viewer and initialize it.
 */
@Override
public void createPartControl(Composite parent) {
    paintCanvas = new Canvas(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    paintCanvas.setLayoutData(gridData);

    // paintSurface
    paintSurface = new PaintSurface(paintCanvas, parent.getDisplay().getSystemColor(
            SWT.COLOR_WHITE));

    tooltip = new ToolTipHandler(parent.getShell());
    tooltip.activateHoverHelp(paintCanvas);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(paintCanvas,
            "de.loskutov.eclipse.jdepend.jdepend"); //$NON-NLS-1$

    if (packages != null) {
        redrawPackages(packages);
    }
}
项目:erflute    文件:ERDiagramOutlinePage.java   
@Override
public void createControl(Composite parent) {
    this.sash = new SashForm(parent, SWT.VERTICAL);
    viewer.createControl(sash);
    editPartFactory = new ERDiagramOutlineEditPartFactory();
    editPartFactory.setQuickMode(quickMode);
    viewer.setEditPartFactory(editPartFactory);
    viewer.setContents(diagram);
    if (!quickMode) {
        final Canvas canvas = new Canvas(sash, SWT.BORDER);
        lws = new LightweightSystem(canvas);
    }
    resetView(registry);
    final AbstractTransferDragSourceListener dragSourceListener =
            new ERDiagramTransferDragSourceListener(viewer, TemplateTransfer.getInstance());
    viewer.addDragSourceListener(dragSourceListener);

    expandVirturalDiagramTree();
}
项目:mytourbook    文件:AbstractRRShell.java   
private Composite createUI_20_PageShellImage(final Composite parent) {

        final Canvas resizeCanvas = new Canvas(//
                parent,
//              SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE//
                SWT.NONE //
        );

        resizeCanvas.setLayout(new FillLayout());

//      resizeCanvas.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_CYAN));

        resizeCanvas.addPaintListener(new PaintListener() {
            @Override
            public void paintControl(final PaintEvent e) {
                onPaintShellImage(e);
            }
        });

        return resizeCanvas;
    }
项目:jo-widgets    文件:CanvasImpl.java   
public CanvasImpl(
    final IGenericWidgetFactory factory,
    final Object parentUiReference,
    final ICanvasSetupSpi setup,
    final SwtImageRegistry imageRegistry) {
    super(factory, new Canvas((Composite) parentUiReference, getStyle(setup)), imageRegistry);
    getUiReference().setBackgroundMode(SWT.INHERIT_DEFAULT);
    this.paintObservable = new PaintObservable();

    getUiReference().addPaintListener(new PaintListener() {
        @Override
        public void paintControl(final PaintEvent e) {
            final Dimension size = getSize();
            final Rectangle bounds = new Rectangle(0, 0, size.getWidth(), size.getHeight());
            final Rectangle clipBounds = new Rectangle(e.x, e.y, e.width, e.height);
            final GraphicContextSpiImpl graphicContext = new GraphicContextSpiImpl(e.gc, bounds, imageRegistry);
            paintObservable.firePaint(new PaintEventSpiImpl(graphicContext, clipBounds));
        }
    });
}
项目:Eclipse-Postfix-Code-Completion    文件:AnnotationExpansionControl.java   
public void mouseExit(MouseEvent e) {

            Item item= (Item) ((Widget) e.getSource()).getData();
            if (item != null)
                item.deselect();

            // if the event lies outside the entire popup, dispose
            org.eclipse.swt.graphics.Region region= fShell.getRegion();
            Canvas can= (Canvas) e.getSource();
            Point p= can.toDisplay(e.x, e.y);
            if (region == null) {
                Rectangle bounds= fShell.getBounds();
//              p= fShell.toControl(p);
                if (!bounds.contains(p))
                    dispose();
            } else {
                p= fShell.toControl(p);
                if (!region.contains(p))
                    dispose();
            }


        }
项目:AcademicTorrents-Downloader    文件:ViewDownSpeedGraph.java   
private void initialize(Composite composite) {
    GridData gridData;

    downSpeedCanvas = new Canvas(composite, SWT.DOUBLE_BUFFERED);
    gridData = new GridData(GridData.FILL_BOTH);
    downSpeedCanvas.setLayoutData(gridData);
    downSpeedGraphic = SpeedGraphic.getInstance();
    downSpeedGraphic.initialize(downSpeedCanvas);
    //downSpeedGraphic.setAutoAlpha(true);
    SWTSkinProperties skinProperties = SWTSkinFactory.getInstance().getSkinProperties();
    Color cBG1 = skinProperties.getColor("color.topbar.speed.bg1");
    Color cBG2 = skinProperties.getColor("color.topbar.speed.bg2");
    Color cBG3 = skinProperties.getColor("color.topbar.speed.bg3");
    downSpeedGraphic.setColors(cBG1, cBG2, cBG3);
    downSpeedGraphic.setLineColors(skinProperties.getColor("color.topbar.speed.average"),
            skinProperties.getColor("color.topbar.speed.value0"),
            skinProperties.getColor("color.topbar.speed.overhead"),
            skinProperties.getColor("color.topbar.speed.value1"),
            skinProperties.getColor("color.topbar.speed.value2plus"),
            skinProperties.getColor("color.topbar.speed.trimmed"));
}
项目:CyclesMod    文件:TorqueGraphDialog.java   
private void createGraph(final Shell shell, final Map<Integer, Short> map, final BikeType bikeType) {
    final Canvas canvas = new Canvas(shell, SWT.NONE);

    final LightweightSystem lws = new LightweightSystem(canvas);
    torqueGraph = new ComplexTorqueGraph(map, bikeType);
    lws.setContents(torqueGraph.getToolbarArmedXYGraph());

    GridDataFactory.fillDefaults().grab(true, true).applyTo(canvas);

    final IXYGraph xyGraph = torqueGraph.getXyGraph();
    canvas.addKeyListener(new ZoomInListener(xyGraph));
    canvas.addKeyListener(new ZoomOutListener(xyGraph));
    canvas.addKeyListener(new UndoListener(xyGraph.getOperationsManager()));
    canvas.addKeyListener(new RedoListener(xyGraph.getOperationsManager()));
    canvas.addKeyListener(new SaveSnapshotListener(shell, xyGraph));

    canvas.addMouseWheelListener(new ZoomMouseWheelListener(xyGraph));

    new ComplexTorqueGraphContextMenu(canvas, torqueGraph);
}
项目:gef-gwt    文件:RulerComposite.java   
/**
 * Calculates the proper trim. Includes scrollbars' sizes only if they're
 * visible.
 * 
 * @param canvas
 *            The canvas.
 * @since 3.6
 */
public static Rectangle calculateEditorTrim(Canvas canvas) {
    /*
     * Workaround for Bug# 87712 Calculating the trim using the clientArea.
     */
    Rectangle bounds = canvas.getBounds();
    Rectangle clientArea = canvas.getClientArea();
    Rectangle result = new Rectangle(0, 0, bounds.width - clientArea.width,
            bounds.height - clientArea.height);
    if (result.width != 0 || result.height != 0) {
        Rectangle trim = canvas.computeTrim(0, 0, 0, 0);
        result.x = result.height == 0 ? 0 : trim.x;
        result.y = result.width == 0 ? 0 : trim.y;
    }
    return result;
}
项目:gef-gwt    文件:GwtRulerComposite.java   
/**
 * Calculates the proper trim. Includes scrollbars' sizes only if they're
 * visible.
 * 
 * @param canvas
 *            The canvas.
 * @since 3.6
 */
public static Rectangle calculateEditorTrim(Canvas canvas) {
    /*
     * Workaround for Bug# 87712 Calculating the trim using the clientArea.
     */
    Rectangle bounds = canvas.getBounds();
    Rectangle clientArea = canvas.getClientArea();
    Rectangle result = new Rectangle(0, 0, bounds.width - clientArea.width,
            bounds.height - clientArea.height);
    if (result.width != 0 || result.height != 0) {
        Rectangle trim = canvas.computeTrim(0, 0, 0, 0);
        result.x = result.height == 0 ? 0 : trim.x;
        result.y = result.width == 0 ? 0 : trim.y;
    }
    return result;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AnnotationExpansionControl.java   
public void mouseExit(MouseEvent e) {

            Item item= (Item) ((Widget) e.getSource()).getData();
            if (item != null)
                item.deselect();

            // if the event lies outside the entire popup, dispose
            org.eclipse.swt.graphics.Region region= fShell.getRegion();
            Canvas can= (Canvas) e.getSource();
            Point p= can.toDisplay(e.x, e.y);
            if (region == null) {
                Rectangle bounds= fShell.getBounds();
//              p= fShell.toControl(p);
                if (!bounds.contains(p))
                    dispose();
            } else {
                p= fShell.toControl(p);
                if (!region.contains(p))
                    dispose();
            }


        }
项目:eclipsegraphviz    文件:GraphicalViewer.java   
public GraphicalViewer(Composite parent) {
    canvas = new Canvas(parent, SWT.NONE);
    parent.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            canvas.setBounds(canvas.getParent().getClientArea());
            requestImageRedraw();
        }
    });
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            redrawImageIfRequested();
            GC gc = e.gc;
            paintCanvas(gc);
        }

    });
}
项目:Environment    文件:ResultAlternativeComposite.java   
private void createChartsComposite (Composite container)
{
    Group grpResources = new Group(container, SWT.NONE);
    grpResources.setText("Resources");
    grpResources.setLayout(new FillLayout(SWT.HORIZONTAL));
    SashForm sashResources = new SashForm(grpResources, SWT.HORIZONTAL | SWT.SMOOTH);
    sashResources.setSashWidth(8);

    listViewer = new ListViewer(sashResources, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    listResources = listViewer.getList();// new List(sashResources,
                                            // SWT.BORDER | SWT.H_SCROLL |
                                            // SWT.V_SCROLL);
    listViewer.setContentProvider(new ArrayContentProvider());
    listViewer.setLabelProvider(new LabelProvider()
    {
        @Override
        public String getText(Object element)
        {
            return element.toString().replaceFirst("-org.spotter.demo.app.", "");
        }
    });
    canvasRes = new Canvas(sashResources, SWT.NONE);
    sashResources.setWeights(new int[] {3, 7});
    addCanvasListeners();
}
项目:eclipsensis    文件:PasteAction.java   
@Override
public void run() {
    PasteCommand command = createPasteCommand();
    if(command != null) {
        InstallOptionsDesignEditor editor = (InstallOptionsDesignEditor)getWorkbenchPart();
        GraphicalViewer viewer = editor.getGraphicalViewer();
        command.setParent((InstallOptionsDialog)editor.getGraphicalViewer().getContents().getModel());
        command.setClientArea(((Canvas)viewer.getControl()).getClientArea());
        List<InstallOptionsEditPart> selection = Common.makeGenericList(InstallOptionsEditPart.class, ((IStructuredSelection)viewer.getSelection()).toList());
        List<InstallOptionsWidget> modelSelection = new ArrayList<InstallOptionsWidget>();
        for (Iterator<InstallOptionsEditPart> iter = selection.iterator(); iter.hasNext();) {
            InstallOptionsEditPart part = iter.next();
            modelSelection.add((InstallOptionsWidget) part.getModel());
        }
        if (!modelSelection.isEmpty())
        {
            command.setSelection(modelSelection);
            execute(command);
        }
    }
}
项目:andes    文件:AttributesTabControl.java   
/**
 * checks for newer values of selected attribute to update the graph
 * @param canvas
 * @param data
 * @throws Exception
 */
private void animate(Canvas canvas, AttributeData data) throws Exception
{
    String attribute = data.getName();
    Object valueObj = MBeanUtility.refreshAttribute(_mbean, attribute);
    int value = Integer.parseInt(String.valueOf(valueObj));
    Object canvasData = canvas.getData(GRAPH_VALUES);
    long[] graphValues = (long[]) canvasData;

    for (int i = 0; i < graphValues.length -1; i++)
    {
        graphValues[i] = graphValues[i + 1];            
    }
    graphValues[graphValues.length - 1] = value;

    canvasData = canvas.getData(MAX_VALUE);
    long maxValue = Long.parseLong(String.valueOf(canvasData));
    if (maxValue < value)
    {
        maxValue = getGraphMaxValue(value);
        canvas.setData(MAX_VALUE, maxValue);
    }

    canvas.redraw();
}
项目:birt    文件:AutoDataBindingViewer.java   
/**
 * main() method for constructing the layout.
 * 
 * @param args
 */
public static void main( String[] args )
{
    Display display = Display.getDefault( );
    Shell shell = new Shell( display );
    shell.setSize( 600, 400 );
    shell.setLayout( new GridLayout( ) );

    Canvas cCenter = new Canvas( shell, SWT.NONE );
    AutoDataBindingViewer adbv = new AutoDataBindingViewer(  );
    cCenter.setLayoutData( new GridData( GridData.FILL_BOTH ) );
    cCenter.addPaintListener( adbv );

    shell.open( );
    while ( !shell.isDisposed( ) )
    {
        if ( !display.readAndDispatch( ) )
            display.sleep( );
    }
    display.dispose( );
}
项目:birt    文件:StyleChartViewer.java   
/**
 * main() method for constructing the layout.
 * 
 * @param args
 */
public static void main( String[] args )
{
    Display display = Display.getDefault( );
    Shell shell = new Shell( display );
    shell.setSize( 600, 400 );
    shell.setLayout( new GridLayout( ) );

    Canvas cCenter = new Canvas( shell, SWT.NONE );
    StyleChartViewer cv = new StyleChartViewer(  );
    cCenter.setLayoutData( new GridData( GridData.FILL_BOTH ) );
    cCenter.addPaintListener( cv );

    shell.open( );
    while ( !shell.isDisposed( ) )
    {
        if ( !display.readAndDispatch( ) )
            display.sleep( );
    }
    display.dispose( );
}
项目:birt    文件:MarkerEditorComposite.java   
void mouseDown( MouseEvent e )
{
    if ( e.widget instanceof Canvas )
    {
        if ( e.widget.getData( ) != null )
        {
            int markerIndex = ( (Integer) e.widget.getData( ) ).intValue( );
            switchMarkerType( markerIndex );

            if ( !this.isDisposed( ) && !this.getShell( ).isDisposed( ) )
            {
                this.getShell( ).close( );
            }
        }           
    }
}
项目:birt    文件:TaskSelectData.java   
private void createPreviewArea( Composite parent )
{
    Composite cmpPreview = ChartUIUtil.createCompositeWrapper( parent );
    {
        GridData gridData = new GridData( GridData.FILL_BOTH );
        gridData.widthHint = CENTER_WIDTH_HINT;
        gridData.heightHint = 200;
        cmpPreview.setLayoutData( gridData );
    }

    Label label = new Label( cmpPreview, SWT.NONE );
    {
        label.setFont( JFaceResources.getBannerFont( ) );
        label.setText( Messages.getString( "TaskSelectData.Label.ChartPreview" ) ); //$NON-NLS-1$
    }

    previewCanvas = new Canvas( cmpPreview, SWT.BORDER );
    {
        GridData gd = new GridData( GridData.FILL_BOTH );
        previewCanvas.setLayoutData( gd );
        previewCanvas.setBackground( Display.getDefault( )
                .getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
    }
}
项目:birt    文件:TaskSelectType.java   
protected void createTopPreviewArea( Composite parent )
{
    Composite cmpPreview = new Composite( parent, SWT.NONE );
    cmpPreview.setLayout( new GridLayout( ) );

    GridData gridData = new GridData( GridData.FILL_BOTH );
    gridData.horizontalSpan = 2;
    gridData.heightHint = 270;
    cmpPreview.setLayoutData( gridData );

    Label label = new Label( cmpPreview, SWT.NONE );
    {
        label.setText( getChartPreviewTitle( ) );
    }

    previewCanvas = new Canvas( cmpPreview, SWT.BORDER );
    previewCanvas.setLayoutData( new GridData( GridData.FILL_BOTH ) );
    previewCanvas.setBackground( Display.getDefault( )
            .getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );

    previewPainter = createPreviewPainter( );
}
项目:maru    文件:SWTMapView.java   
@Override
public void createPartControl(final Composite parent)
{
    setContainer(new Canvas(parent, SWT.DOUBLE_BUFFERED));
    getContainer().setLayout(new FillLayout());
    getContainer().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));

    setMapDrawer(new SWTMapDrawer(this));

    addMapPaintListener();
    addMapResizeListener();
    addMouseListener();

    MaruUIPlugin.getDefault().getUiModel().addUiProjectModelListener(this);
    MaruUIPlugin.getDefault().getUiModel().addUiProjectSelectionListener(this);
}
项目:Mailster    文件:SearchBoxLayout.java   
protected void layout(Composite composite, boolean flushCache)
{
    if (t == null || flushCache)
    {
        Control[] ctrls = composite.getChildren();
        for (Control c : ctrls)
        {
            if (c instanceof Text)
                t = (Text) c;
            else
                canvas = (Canvas) c;
        }
    }

    Point size = composite.getSize();
    Point tmp = canvas.getSize();
    Point pt = new Point(size.x - tmp.x - SPACING - (2 * MARGIN), tmp.y);

    int h = t.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y;
    if (h % 2 != 0)
        h += 1;
    t.setBounds(MARGIN, MARGIN + (tmp.y - h) / 2, pt.x, h);
    canvas.setLocation(pt.x + SPACING + MARGIN, MARGIN);
}
项目:waazdoh.music.swt    文件:AudioLevelMeter.java   
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public AudioLevelMeter(Composite parent, int style) {
    super(parent, style);
    setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
    setLayout(new FillLayout(SWT.HORIZONTAL));
    canvas = new Canvas(this, SWT.NONE);
    canvas.setBackground(SWTResourceManager
            .getColor(SWT.COLOR_WIDGET_BACKGROUND));
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            Rectangle clientArea = canvas.getBounds();
            float w = clientArea.width * level;
            int y = clientArea.height;
            e.gc.fillRectangle(0, y, (int) w, (int) y);
        }
    });
}
项目:convertigo-eclipse    文件:AnimatedGif.java   
public AnimatedGif(Display display, Canvas animationCanvas, String animatedGifFile) {
    this.display = display;
    this.animationCanvas = animationCanvas;

    try {
        loader = new ImageLoader();
    } catch (SWTException ex) {
        ConvertigoPlugin.logException(ex, "There was an error loading the GIF", false);
        loader = null;
    }
    imageDataArray = loader.load(getClass().getResourceAsStream(animatedGifFile));
    animationCanvasGC = new GC(animationCanvas);
    shellBackground = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
}
项目:convertigo-eclipse    文件:ConnectorEditorPart.java   
/**
 * This method initializes compositeOutputHeader
 * 
 */
private void createCompositeOutputHeader() {
    final Color background = getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);

    GridLayout gridLayout3 = new GridLayout();
    gridLayout3.numColumns = 2;
    GridData gridData1 = new org.eclipse.swt.layout.GridData();
    gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
    gridData1.grabExcessHorizontalSpace = true;
    gridData1.grabExcessVerticalSpace = false;
    gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING;
    compositeOutputHeader = new Composite(compositeOutput, SWT.NONE);
    compositeOutputHeader.setBackground(background);
    compositeOutputHeader.setLayoutData(gridData1);
    compositeOutputHeader.setLayout(gridLayout3);

    createToolBar();

    GridData gridData6 = new org.eclipse.swt.layout.GridData();
    gridData6.horizontalAlignment = org.eclipse.swt.layout.GridData.END;
    gridData6.heightHint = 16;
    gridData6.widthHint = 104;
    gridData6.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING;

    canvas = new Canvas(compositeOutputHeader, SWT.NONE);
    canvas.setLayoutData(gridData6);
    canvas.setVisible(true);
}
项目:convertigo-eclipse    文件:SequenceEditorPart.java   
private void createCompositeOutputHeader() {
    final Color background = getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);

    GridLayout gridLayout3 = new GridLayout();
    gridLayout3.numColumns = 2;
    GridData gridData1 = new org.eclipse.swt.layout.GridData();
    gridData1.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
    gridData1.grabExcessHorizontalSpace = true;
    gridData1.grabExcessVerticalSpace = false;
    gridData1.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING;
    compositeOutputHeader = new Composite(compositeOutput, SWT.NONE);
    compositeOutputHeader.setBackground(background);
    compositeOutputHeader.setLayoutData(gridData1);
    compositeOutputHeader.setLayout(gridLayout3);

    createToolBar();

    GridData gridData6 = new org.eclipse.swt.layout.GridData();
    gridData6.horizontalAlignment = org.eclipse.swt.layout.GridData.END;
    gridData6.heightHint = 16;
    gridData6.widthHint = 104;
    gridData6.verticalAlignment = org.eclipse.swt.layout.GridData.BEGINNING;

    canvas = new Canvas(compositeOutputHeader, SWT.NONE);
    canvas.setLayoutData(gridData6);
    canvas.setVisible(false);
}