Package org.eclipse.wb.draw2d

Examples of org.eclipse.wb.draw2d.Figure


  }

  @Override
  protected void refreshVisuals() {
    super.refreshVisuals();
    Figure figure = getFigure();
    // bounds
    {
      int index = getIndex();
      Interval interval = m_panel.getGridInfo().getColumnIntervals()[index];
      Rectangle bounds =
          new Rectangle(interval.begin,
              0,
              interval.length + 1,
              ((GraphicalEditPart) getParent()).getFigure().getSize().height);
      bounds.translate(getOffset().x, 0);
      figure.setBounds(bounds);
    }
  }
View Full Code Here


  // Figure
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected Figure createFigure() {
    Figure newFigure = new Figure() {
      @Override
      protected void paintClientArea(Graphics graphics) {
        Rectangle r = getClientArea();
        // draw rectangle
        graphics.setForegroundColor(IColorConstants.buttonDarker);
        graphics.drawLine(r.x, r.y, r.right(), r.y);
        graphics.drawLine(r.x, r.bottom() - 1, r.right(), r.bottom() - 1);
        // draw row index
        int titleTop;
        {
          String title = "" + getIndex();
          Dimension textExtents = graphics.getTextExtent(title);
          if (r.height < textExtents.height) {
            return;
          }
          // draw title
          titleTop = r.y + (r.height - textExtents.height) / 2;
          int x = r.x + (r.width - textExtents.width) / 2;
          graphics.setForegroundColor(IColorConstants.black);
          graphics.drawText(title, x, titleTop);
        }
        // draw alignment indicator
        if (titleTop - r.y > 3 + 7 + 3) {
          Image image = m_row.getAlignment().getSmallImage();
          if (image != null) {
            int y = r.y + 2;
            drawCentered(graphics, image, y);
          }
        }
      }

      private void drawCentered(Graphics graphics, Image image, int y) {
        int x = (getBounds().width - image.getBounds().width) / 2;
        graphics.drawImage(image, x, y);
      }
    };
    //
    newFigure.setFont(DEFAULT_FONT);
    newFigure.setOpaque(true);
    return newFigure;
  }
View Full Code Here

  }

  @Override
  protected void refreshVisuals() {
    super.refreshVisuals();
    Figure figure = getFigure();
    // bounds
    {
      int index = getIndex();
      Interval interval = m_panel.getGridInfo().getRowIntervals()[index];
      Rectangle bounds =
          new Rectangle(0,
              interval.begin,
              ((GraphicalEditPart) getParent()).getFigure().getSize().width,
              interval.length + 1);
      bounds.translate(0, getOffset().y);
      figure.setBounds(bounds);
    }
  }
View Full Code Here

  /**
   * Implementation of {@link ILocator} to place handle directly on header.
   */
  private class HeaderMoveHandleLocator implements ILocator {
    public void relocate(Figure target) {
      Figure reference = getHostFigure();
      Rectangle bounds = reference.getBounds().getCopy();
      FigureUtils.translateFigureToFigure(reference, target, bounds);
      target.setBounds(bounds);
    }
View Full Code Here

  // Figure
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected Figure createFigure() {
    return new Figure();
  }
View Full Code Here

  /**
   * Implementation of {@link ILocator} to place handle directly on header.
   */
  private class HeaderMoveHandleLocator implements ILocator {
    public void relocate(Figure target) {
      Figure reference = getHostFigure();
      Rectangle bounds = reference.getBounds().getCopy();
      FigureUtils.translateFigureToFigure(reference, target, bounds);
      target.setBounds(bounds);
    }
View Full Code Here

              "// filler filler filler filler filler",
              "<ui:UiBinder>",
              "  <g:FlowPanel/>",
              "</ui:UiBinder>");
      GraphicalEditPart panelEditPart = canvas.getEditPart(originalPanel);
      Figure panelFigure = panelEditPart.getFigure();
      // no device yet
      assertEquals(new Rectangle(20, 20, 450, 300), panelFigure.getBounds());
      // set device
      DeviceSelectionSupport.setDevice(originalPanel, DeviceManager.getDevice("generic.qvga"));
      assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
    }
    // parse again
    {
      openSourcePage();
      m_lastContext.getDocument().replace(0, 0, " ");
      openDesignPage();
      fetchContentFields();
    }
    // ...still has device
    {
      assertNotSame(originalPanel, m_contentObject);
      GraphicalEditPart panelEditPart = canvas.getEditPart(m_contentObject);
      Figure panelFigure = panelEditPart.getFigure();
      assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
    }
  }
View Full Code Here

  // Figure
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected Figure createFigure() {
    Figure newFigure = new Figure() {
      @Override
      protected void paintClientArea(Graphics graphics) {
        Rectangle r = getClientArea();
        // draw rectangle
        graphics.setForegroundColor(IColorConstants.buttonDarker);
        graphics.drawLine(r.x, r.y, r.right(), r.y);
        graphics.drawLine(r.x, r.bottom() - 1, r.right(), r.bottom() - 1);
        // draw row index
        int titleTop;
        {
          String title = "" + (1 + m_dimension.getIndex());
          Dimension textExtents = graphics.getTextExtent(title);
          if (r.height < 3 + textExtents.height + 3) {
            return;
          }
          // draw title
          titleTop = r.y + (r.height - textExtents.height) / 2;
          int x = r.x + (r.width - textExtents.width) / 2;
          graphics.setForegroundColor(IColorConstants.black);
          graphics.drawText(title, x, titleTop);
        }
      }
    };
    //
    newFigure.setFont(DEFAULT_FONT);
    newFigure.setOpaque(true);
    return newFigure;
  }
View Full Code Here

    }
  }

  private AbstractPopupFigure getAlignFigure(final int width, final int height) {
    final AbstractPopupFigure[] popupFigure = {null};
    Figure layer = m_viewerCanvas.getLayer(IEditPartViewer.CLICKABLE_LAYER);
    layer.accept(new FigureVisitor() {
      private final int MARGIN = 6;

      @Override
      public void endVisit(Figure figure) {
        if (figure instanceof AbstractPopupFigure) {
View Full Code Here

              "public class Test extends FlowPanel {",
              "  public Test() {",
              "  }",
              "}");
      GraphicalEditPart panelEditPart = canvas.getEditPart(originalPanel);
      Figure panelFigure = panelEditPart.getFigure();
      // no device yet
      assertEquals(new Rectangle(20, 20, 450, 300), panelFigure.getBounds());
      assertTrue(hasTopSelectionPolicy(panelEditPart));
      // set device
      DeviceSelectionSupport.setDevice(originalPanel, DeviceManager.getDevice("generic.qvga"));
      assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
      assertFalse(hasTopSelectionPolicy(panelEditPart));
    }
    // parse again
    {
      openSourcePage();
      m_lastEditor.replaceSubstring(0, 0, " ");
      m_lastEditor.commitChanges();
      openDesignPage();
      fetchContentFields();
    }
    // ...still has device
    {
      ComplexPanelInfo newPanel = (ComplexPanelInfo) m_contentJavaInfo;
      assertNotSame(originalPanel, newPanel);
      // has device
      assertNotNull(DeviceSelectionSupport.getDevice(newPanel));
      // device bounds applied
      GraphicalEditPart panelEditPart = canvas.getEditPart(newPanel);
      Figure panelFigure = panelEditPart.getFigure();
      assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
      assertFalse(hasTopSelectionPolicy(panelEditPart));
      // remove device
      DeviceSelectionSupport.setDevice(newPanel, null);
      assertEquals(new Rectangle(20, 20, 240, 320), panelFigure.getBounds());
      assertTrue(hasTopSelectionPolicy(panelEditPart));
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wb.draw2d.Figure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.