Package org.eclipse.wb.draw2d

Examples of org.eclipse.wb.draw2d.Figure


            "public class Test extends FlowPanel {",
            "  public Test() {",
            "  }",
            "}");
    GraphicalEditPart panelEditPart = canvas.getEditPart(panel);
    Figure panelFigure = panelEditPart.getFigure();
    // set device
    {
      DeviceSelectionSupport.setDevice(panel, DeviceManager.getDevice("generic.qvga"));
      assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
      assertSame(Orientation.PORTRAIT, DeviceSelectionSupport.getOrientation(panel));
    }
    // set orientation
    {
      DeviceSelectionSupport.setOrientation(panel, Orientation.LANDSCAPE);
      assertEquals(new Rectangle(25, 25, 320, 240), panelFigure.getBounds());
      assertSame(Orientation.LANDSCAPE, DeviceSelectionSupport.getOrientation(panel));
    }
  }
View Full Code Here


            "public class Test extends FlowPanel {",
            "  public Test() {",
            "  }",
            "}");
    GraphicalEditPart panelEditPart = canvas.getEditPart(panel);
    Figure panelFigure = panelEditPart.getFigure();
    // no device yet
    assertEquals(new Rectangle(20, 20, 450, 300), panelFigure.getBounds());
    // set device
    {
      UiContext context = new UiContext();
      // click ToolItem to open Menu
      ToolItem deviceToolItem = context.getToolItem("No device");
      context.click(deviceToolItem, SWT.ARROW);
      // click "device" MenuItem
      {
        Menu menu = (Menu) deviceToolItem.getData("designTimeMenu");
        MenuItem menuItem = context.getMenuItem(menu, "QVGA");
        context.click(menuItem);
      }
    }
    // new bounds
    assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
    // flip orientation
    {
      UiContext context = new UiContext();
      ToolItem deviceToolItem = context.getToolItem("Flip orientation");
      // PORTRAIT -> LANDSCAPE
      context.click(deviceToolItem);
      assertEquals(new Rectangle(25, 25, 320, 240), panelFigure.getBounds());
      // LANDSCAPE -> PORTRAIT
      context.click(deviceToolItem);
      assertEquals(new Rectangle(25, 25, 240, 320), panelFigure.getBounds());
    }
  }
View Full Code Here

      }
    }
    // prepare bounds
    Rectangle bounds;
    {
      Figure hostFigure = getHostFigure();
      bounds = request.getTransformedRectangle(hostFigure.getBounds());
      FigureUtils.translateFigureToAbsolute(hostFigure, bounds.shrink(-1, -1));
    }
    // update selection feedback
    m_resizeFeedback.setBounds(bounds);
    // update text feedback
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.x, r.bottom());
        graphics.drawLine(r.right() - 1, r.y, r.right() - 1, r.bottom());
        // draw column index
        int titleLeft;
        {
          String title = "" + (1 + m_dimension.getIndex());
          Dimension textExtents = graphics.getTextExtent(title);
          if (r.width < 3 + textExtents.width + 3) {
            return;
          }
          // draw title
          titleLeft = r.x + (r.width - textExtents.width) / 2;
          int y = r.y + (r.height - textExtents.height) / 2;
          graphics.setForegroundColor(IColorConstants.black);
          graphics.drawText(title, titleLeft, y);
        }
      }
    };
    //
    newFigure.setFont(DEFAULT_FONT);
    newFigure.setOpaque(true);
    return newFigure;
  }
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

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

  @Override
  protected void addChildVisual(EditPart childPart, int index) {
    // update "index" to put portlets on Portal figure after Column figure
    {
      Figure portalFigure = getContentPane();
      Figure columnFigure = getFigure();
      int columnFigureIndex = portalFigure.getChildren().indexOf(columnFigure);
      index += columnFigureIndex + 1;
    }
    // do add
    super.addChildVisual(childPart, index);
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.x, r.bottom());
        graphics.drawLine(r.right() - 1, r.y, r.right() - 1, r.bottom());
        // draw column index
        int titleLeft;
        {
          String title = "" + (1 + m_dimension.getIndex());
          Dimension textExtents = graphics.getTextExtent(title);
          if (r.width < 3 + textExtents.width + 3) {
            return;
          }
          // draw title
          titleLeft = r.x + (r.width - textExtents.width) / 2;
          int y = r.y + (r.height - textExtents.height) / 2;
          graphics.setForegroundColor(IColorConstants.black);
          graphics.drawText(title, titleLeft, y);
        }
      }
    };
    //
    newFigure.setFont(DEFAULT_FONT);
    newFigure.setOpaque(true);
    return newFigure;
  }
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

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.