コード例 #1
0
  @Override
  protected IFigure createFigure() {
    Figure f = new FreeformViewport();
    ToolbarLayout tb = new AnimationLayoutManager(true);
    tb.setSpacing(30);
    tb.setStretchMinorAxis(false);
    f.setLayoutManager(tb);
    f.setBorder(
        new MarginBorder(
            DiagramModel.TOP_MARGIN,
            DiagramModel.SIDE_MARGIN,
            DiagramModel.BOTTOM_MARGIN,
            DiagramModel.SIDE_MARGIN));
    f.addMouseMotionListener(this);
    f.setBackgroundColor(ColorScheme.diagramBackground);
    IFigure label =
        new Label(
            " \n Drag classes or methods from the Package Explorer "
                + "into the diagram to explore and understand code."
                + "\n Or, use the expandable Palette on the right side of the diagram "
                + "to design.");
    this.nonEmptyFigure = new NonEmptyFigure(label);
    NonEmptyFigureSupport.instructionHighlight(label, 10);
    f.add(nonEmptyFigure);

    warning = new Label("");
    warning.setLayoutManager(new ToolbarLayout());
    NonEmptyFigureSupport.instructionHighlight(warning, 10);
    f.add(warning);
    return f;
  }
コード例 #2
0
  private void addInstancePanel() {
    final Figure instancePanel = new Figure();
    instancePanel.setSize(new Dimension(300, DiagramModel.TOP_MARGIN));
    ToolbarLayout tb = new AnimationLayoutManager(true);
    tb.setSpacing(30);
    tb.setStretchMinorAxis(false);
    instancePanel.setLayoutManager(tb);
    instancePanel.setBackgroundColor(ColorScheme.instancePanelBackground);
    instancePanel.setOpaque(true);
    BottomShadowBorder bottomBorder = new BottomShadowBorder();
    bottomBorder.setColor(ColorScheme.instancePanelBottomBorder);
    int allSides = DiagramModel.INSTANCE_PANEL_MARGINS;
    instancePanel.setBorder(
        new CompoundBorder(bottomBorder, new MarginBorder(allSides, allSides, allSides, allSides)));

    ((DiagramModel) getModel()).setInstancePanel(instancePanel);

    SeqOrderedLayoutEditPolicy policy =
        (SeqOrderedLayoutEditPolicy) getEditPolicy(EditPolicy.LAYOUT_ROLE);
    policy.addInstancesPanel(instancePanel);

    getFigure()
        .addFigureListener(
            new FigureListener() {
              public void figureMoved(IFigure source) {
                instancePanel.setSize(
                    getFigure().getBounds().width, instancePanel.getBounds().height);
              }
            });
  }