예제 #1
0
  /**
   * Given a label figure object, this will calculate the correct Font needed to display into screen
   * coordinates, taking into account the current mapmode. This will typically be used by direct
   * edit cell editors that need to display independent of the zoom or any coordinate mapping that
   * is taking place on the drawing surface.
   *
   * @param label the label to use for the font calculation
   * @return the <code>Font</code> that is scaled to the screen coordinates. Note: the returned
   *     <code>Font</code> should not be disposed since it is cached by a common resource manager.
   */
  protected Font getScaledFont(IFigure label) {
    Font scaledFont = label.getFont();
    FontData data = scaledFont.getFontData()[0];
    Dimension fontSize = new Dimension(0, MapModeUtil.getMapMode(label).DPtoLP(data.getHeight()));
    label.translateToAbsolute(fontSize);

    if (Math.abs(data.getHeight() - fontSize.height) < 2) fontSize.height = data.getHeight();

    try {
      FontDescriptor fontDescriptor = FontDescriptor.createFrom(data);
      cachedFontDescriptors.add(fontDescriptor);
      return getResourceManager().createFont(fontDescriptor);
    } catch (DeviceResourceException e) {
      Trace.catching(
          DiagramUIPlugin.getInstance(),
          DiagramUIDebugOptions.EXCEPTIONS_CATCHING,
          getClass(),
          "getScaledFont",
          e); //$NON-NLS-1$
      Log.error(
          DiagramUIPlugin.getInstance(),
          DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
          "getScaledFont",
          e); //$NON-NLS-1$
    }
    return JFaceResources.getDefaultFont();
  }
 /** @generated */
 public Edge createViewTableViewedTables_3002(
     View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
   Edge edge = NotationFactory.eINSTANCE.createEdge();
   edge.getStyles().add(NotationFactory.eINSTANCE.createRoutingStyle());
   edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
   RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
   ArrayList points = new ArrayList(2);
   points.add(new RelativeBendpoint());
   points.add(new RelativeBendpoint());
   bendpoints.setPoints(points);
   edge.setBendpoints(bendpoints);
   ViewUtil.insertChildView(containerView, edge, index, persisted);
   edge.setType(SqlmodelVisualIDRegistry.getType(ViewTableViewedTables2EditPart.VISUAL_ID));
   edge.setElement(null);
   // initializePreferences
   final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
   FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE);
   if (edgeFontStyle != null) {
     FontData fontData =
         PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
     edgeFontStyle.setFontName(fontData.getName());
     edgeFontStyle.setFontHeight(fontData.getHeight());
     edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
     edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
     org.eclipse.swt.graphics.RGB fontRGB =
         PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
     edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
   }
   Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE));
   if (routing != null) {
     ViewUtil.setStructuralFeatureValue(
         edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
   }
   return edge;
 }
 /** 사용자 폰트를 설정합니다. */
 private void setFontData() {
   FontDialog fd = new FontDialog(getShell(), SWT.NONE);
   FontData fdFont = fd.open();
   if (fdFont != null) {
     lblUserFont.setText(fdFont.getName() + "|" + fdFont.getHeight() + "|" + fdFont.getStyle());
   }
 }
  /**
   * Replaces the following style attributes of the font definition of the <code>html</code>
   * element:
   *
   * <ul>
   *   <li>font-size
   *   <li>font-weight
   *   <li>font-style
   *   <li>font-family
   * </ul>
   *
   * The font's name is used as font family, a <code>sans-serif</code> default font family is
   * appended for the case that the given font name is not available.
   *
   * <p>If the listed font attributes are not contained in the passed style list, nothing happens.
   *
   * @param styles CSS style definitions
   * @param fontData the font information to use
   * @return the modified style definitions
   * @since 3.3
   */
  public static String convertTopLevelFont(String styles, FontData fontData) {
    boolean bold = (fontData.getStyle() & SWT.BOLD) != 0;
    boolean italic = (fontData.getStyle() & SWT.ITALIC) != 0;
    String size = Integer.toString(fontData.getHeight()) + UNIT;
    String family = "'" + fontData.getName() + "',sans-serif"; // $NON-NLS-1$ //$NON-NLS-2$

    styles =
        styles.replaceFirst(
            "(html\\s*\\{.*(?:\\s|;)font-size:\\s*)\\d+pt(\\;?.*\\})",
            "$1" + size + "$2"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    styles =
        styles.replaceFirst(
            "(html\\s*\\{.*(?:\\s|;)font-weight:\\s*)\\w+(\\;?.*\\})",
            "$1"
                + (bold ? "bold" : "normal")
                + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    styles =
        styles.replaceFirst(
            "(html\\s*\\{.*(?:\\s|;)font-style:\\s*)\\w+(\\;?.*\\})",
            "$1"
                + (italic ? "italic" : "normal")
                + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    styles =
        styles.replaceFirst(
            "(html\\s*\\{.*(?:\\s|;)font-family:\\s*).+?(;.*\\})",
            "$1" + family + "$2"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    return styles;
  }
예제 #5
0
파일: Header.java 프로젝트: dave68/opal
  private void initFontAndColors() {
    final Font defaultFont;
    final FontData[] fontData = getFont().getFontData();
    if (fontData != null && fontData.length > 0) {
      final FontData fd = fontData[0];
      fd.setStyle(SWT.BOLD);
      fd.setHeight(fd.getHeight() + 2);
      defaultFont = new Font(getDisplay(), fd);
    } else {
      defaultFont = null;
    }
    this.titleFont = defaultFont;
    SWTGraphicUtil.addDisposer(this, defaultFont);

    final Color defaultTitleColor = new Color(getDisplay(), 0, 88, 150);
    this.titleColor = defaultTitleColor;
    SWTGraphicUtil.addDisposer(this, defaultTitleColor);

    final Color defaultGradientEndColor = new Color(this.getDisplay(), 239, 239, 239);
    this.gradientEnd = defaultGradientEndColor;
    SWTGraphicUtil.addDisposer(this, defaultGradientEndColor);

    final Color defaultGradientStartColor = new Color(this.getDisplay(), 255, 255, 255);
    this.gradientStart = defaultGradientStartColor;
    SWTGraphicUtil.addDisposer(this, defaultGradientStartColor);

    final Color defaultSeparatorColor = new Color(this.getDisplay(), 229, 229, 229);
    this.separatorColor = defaultSeparatorColor;
    SWTGraphicUtil.addDisposer(this, defaultSeparatorColor);
  }
예제 #6
0
  /**
   * Returns a version of the specified FontData, resized by the requested size.
   *
   * @param fontData the font-data to resize
   * @param size the font size
   * @return resized font data
   */
  public static FontData[] resizeFont(FontData[] fontData, int size) {
    for (FontData data : fontData) {
      data.setHeight(data.getHeight() + size);
    }

    return fontData;
  }
  /** @generated */
  public Edge createAssociation_4001(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Connector edge = NotationFactory.eINSTANCE.createConnector();
    edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
    RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
    ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
    points.add(new RelativeBendpoint());
    points.add(new RelativeBendpoint());
    bendpoints.setPoints(points);
    edge.setBendpoints(bendpoints);
    ViewUtil.insertChildView(containerView, edge, index, persisted);
    edge.setType(
        edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
            .NECSIS14_ClassDiagramVisualIDRegistry.getType(
            edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
                .AssociationEditPart.VISUAL_ID));
    edge.setElement(domainElement);
    // initializePreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();

    org.eclipse.swt.graphics.RGB lineRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR);
    ViewUtil.setStructuralFeatureValue(
        edge,
        NotationPackage.eINSTANCE.getLineStyle_LineColor(),
        FigureUtilities.RGBToInteger(lineRGB));
    FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (edgeFontStyle != null) {
      FontData fontData =
          PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
      edgeFontStyle.setFontName(fontData.getName());
      edgeFontStyle.setFontHeight(fontData.getHeight());
      edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
      org.eclipse.swt.graphics.RGB fontRGB =
          PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
      edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
    Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE));
    if (routing != null) {
      ViewUtil.setStructuralFeatureValue(
          edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
    }
    Node label6001 =
        createLabel(
            edge,
            edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
                .NECSIS14_ClassDiagramVisualIDRegistry.getType(
                edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
                    .AssociationNameEditPart.VISUAL_ID));
    label6001.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
    Location location6001 = (Location) label6001.getLayoutConstraint();
    location6001.setX(0);
    location6001.setY(40);
    return edge;
  }
예제 #8
0
  /**
   * Replaces the following style attributes of the font definition of the <code>html</code>
   * element:
   *
   * <ul>
   *   <li>font-size
   *   <li>font-weight
   *   <li>font-style
   *   <li>font-family
   * </ul>
   *
   * The font's name is used as font family, a <code>sans-serif</code> default font family is
   * appended for the case that the given font name is not available.
   *
   * <p>If the listed font attributes are not contained in the passed style list, nothing happens.
   *
   * @param styles CSS style definitions
   * @param fontData the font information to use
   * @return the modified style definitions
   * @since 3.3
   */
  public static String convertTopLevelFont(String styles, FontData fontData) {
    boolean bold = (fontData.getStyle() & SWT.BOLD) != 0;
    boolean italic = (fontData.getStyle() & SWT.ITALIC) != 0;

    // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=155993
    String size =
        Integer.toString(fontData.getHeight())
            + ("carbon".equals(SWT.getPlatform())
                ? "px"
                : "pt"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    String family = "'" + fontData.getName() + "',sans-serif"; // $NON-NLS-1$ //$NON-NLS-2$
    styles =
        styles.replaceFirst(
            "(html\\s*\\{.*(?:\\s|;)font-size:\\s*)\\d+pt(\\;?.*\\})",
            "$1" + size + "$2"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    styles =
        styles.replaceFirst(
            "(html\\s*\\{.*(?:\\s|;)font-weight:\\s*)\\w+(\\;?.*\\})",
            "$1"
                + (bold ? "bold" : "normal")
                + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    styles =
        styles.replaceFirst(
            "(html\\s*\\{.*(?:\\s|;)font-style:\\s*)\\w+(\\;?.*\\})",
            "$1"
                + (italic ? "italic" : "normal")
                + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    styles =
        styles.replaceFirst(
            "(html\\s*\\{.*(?:\\s|;)font-family:\\s*).+?(;.*\\})",
            "$1" + family + "$2"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    return styles;
  }
예제 #9
0
 private void update(FontData data) {
   this.fontData[0] = data;
   this.selectedFont = GUIHelper.getFont(data);
   setText(data.getName() + ", " + data.getHeight() + "pt");
   setFont(createDisplayFont(data));
   setAlignment(SWT.CENTER);
   setToolTipText("Click to select font");
 }
예제 #10
0
  /**
   * Returns a version of the specified font, resized by the requested size.
   *
   * @param font the font to resize
   * @param size the font size
   * @return resized font data
   */
  public static FontData[] resizeFont(Font font, int size) {
    FontData[] datas = font.getFontData();
    for (FontData data : datas) {
      data.setHeight(data.getHeight() + size);
    }

    return datas;
  }
예제 #11
0
 void paintCanvas(Event event) {
   canvas.setCursor(null);
   int index = list.getSelectionIndex();
   if (index == -1) return;
   GC gc = event.gc;
   Object object = objects[index];
   if (object instanceof Color) {
     if (((Color) object).isDisposed()) return;
     gc.setBackground((Color) object);
     gc.fillRectangle(canvas.getClientArea());
     return;
   }
   if (object instanceof Cursor) {
     if (((Cursor) object).isDisposed()) return;
     canvas.setCursor((Cursor) object);
     return;
   }
   if (object instanceof Font) {
     if (((Font) object).isDisposed()) return;
     gc.setFont((Font) object);
     FontData[] array = gc.getFont().getFontData();
     StringBuffer sb = new StringBuffer();
     String lf = text.getLineDelimiter();
     for (int i = 0; i < array.length; i++) {
       FontData data = array[i];
       String style = "NORMAL"; // $NON-NLS-1$
       int bits = data.getStyle();
       if (bits != 0) {
         if ((bits & SWT.BOLD) != 0) style = "BOLD "; // $NON-NLS-1$
         if ((bits & SWT.ITALIC) != 0) style += "ITALIC"; // $NON-NLS-1$
       }
       sb.append(data.getName())
           .append(" ")
           .append(data.getHeight()) // $NON-NLS-1$
           .append(" ")
           .append(style)
           .append(lf); // $NON-NLS-1$
     }
     gc.drawString(sb.toString(), 0, 0);
     return;
   }
   // NOTHING TO DRAW FOR GC
   // if (object instanceof GC) {
   // return;
   // }
   if (object instanceof Image) {
     if (((Image) object).isDisposed()) return;
     gc.drawImage((Image) object, 0, 0);
     return;
   }
   if (object instanceof Region) {
     if (((Region) object).isDisposed()) return;
     String string = ((Region) object).getBounds().toString();
     gc.drawString(string, 0, 0);
     return;
   }
 }
예제 #12
0
  /** Copied from {@link FontRegistry} */
  private static FontData[] getModifiedFontData(FontData[] baseData, int style) {
    FontData[] styleData = new FontData[baseData.length];
    for (int i = 0; i < styleData.length; i++) {
      FontData base = baseData[i];
      styleData[i] = new FontData(base.getName(), base.getHeight(), base.getStyle() | style);
    }

    return styleData;
  }
예제 #13
0
 private static void appendFontData(final StringBuffer buffer) {
   final String size =
       Integer.toString(fontData.getHeight()) + ("carbon".equals(SWT.getPlatform()) ? "px" : "pt");
   buffer
       .append("<style type=\"text/css\">body {font-size:")
       .append(size)
       .append("; font-family:'")
       .append(fontData.getName())
       .append("',serif;}</style>");
 }
예제 #14
0
 /**
  * Get the text font
  *
  * @return
  */
 private String getCssFont() {
   StringBuilder result = new StringBuilder();
   if (getFont() != null) {
     FontData data = getFont().getFontData()[0];
     result.append(data.getHeight());
     result.append("px ");
     result.append(data.getName());
   }
   return result.toString();
 }
예제 #15
0
 /**
  * Returns a bold version of the given {@link Font}.
  *
  * @param baseFont the {@link Font} for which a bold version is desired
  * @return the bold version of the given {@link Font}
  */
 public static Font getBoldFont(Font baseFont) {
   Font font = m_fontToBoldFontMap.get(baseFont);
   if (font == null) {
     FontData fontDatas[] = baseFont.getFontData();
     FontData data = fontDatas[0];
     font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
     m_fontToBoldFontMap.put(baseFont, font);
   }
   return font;
 }
  /** @generated */
  public Node createViewTable_1002(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Node node = NotationFactory.eINSTANCE.createNode();
    node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
    node.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());

    FillStyle fillStyle = NotationFactory.eINSTANCE.createFillStyle();
    Color color = ViewTableEditPart.getDeclaredBackgroundColor();
    fillStyle.setFillColor(FigureUtilities.colorToInteger(color));
    node.getStyles().add(fillStyle);
    LineStyle lineStyle = NotationFactory.eINSTANCE.createLineStyle();
    lineStyle.setLineColor(FigureUtilities.RGBToInteger(new org.eclipse.swt.graphics.RGB(0, 0, 0)));
    node.getStyles().add(lineStyle);

    node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
    node.setType(SqlmodelVisualIDRegistry.getType(ViewTableEditPart.VISUAL_ID));
    ViewUtil.insertChildView(containerView, node, index, persisted);
    node.setElement(domainElement);
    stampShortcut(containerView, node);
    // initializeFromPreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
    FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (nodeFontStyle != null) {
      FontData fontData =
          PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
      nodeFontStyle.setFontName(fontData.getName());
      nodeFontStyle.setFontHeight(fontData.getHeight());
      nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
      org.eclipse.swt.graphics.RGB fontRGB =
          PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
      nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
    Node label4002 =
        createLabel(node, SqlmodelVisualIDRegistry.getType(ViewTableNameEditPart.VISUAL_ID));
    createCompartment(
        node,
        SqlmodelVisualIDRegistry.getType(ViewTableViewedColumnsEditPart.VISUAL_ID),
        false,
        false,
        true,
        true);
    createCompartment(
        node,
        SqlmodelVisualIDRegistry.getType(ViewTableViewedTablesEditPart.VISUAL_ID),
        false,
        false,
        true,
        true);
    return node;
  }
예제 #17
0
 private static FontData[] getModifiedFontData(FontData[] originalData, int additionalStyle) {
   FontData[] styleData = new FontData[originalData.length];
   for (int i = 0; i < styleData.length; i++) {
     FontData base = originalData[i];
     styleData[i] =
         new FontData(base.getName(), base.getHeight(), base.getStyle() | additionalStyle);
     // System.out.println("FONT = "+ base.getName());
     // System.out.println("FONT getHeight= "+ base.getHeight());
   }
   return styleData;
 }
예제 #18
0
 private void refontLabel(boolean dye) {
   FontData fontData = label.getFont().getFontData()[0];
   Font font;
   int color;
   if (dye) {
     font =
         new Font(
             label.getParent().getDisplay(),
             new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
     color = SWT.COLOR_RED;
   } else {
     font =
         new Font(
             label.getParent().getDisplay(),
             new FontData(fontData.getName(), fontData.getHeight(), SWT.NONE));
     color = SWT.COLOR_WIDGET_FOREGROUND;
   }
   label.setForeground(label.getParent().getDisplay().getSystemColor(color));
   label.setFont(font);
 }
예제 #19
0
 protected void setButtonFontData(Button button, FontData fontData) {
   String text = fontData.getName();
   if ((fontData.getStyle() & SWT.BOLD) != 0) {
     text += " Bold";
   }
   if ((fontData.getStyle() & SWT.ITALIC) != 0) {
     text += " Italic";
   }
   text += (" " + fontData.getHeight());
   button.setText(text);
 }
예제 #20
0
  private static Font getItalicFont(Font font) {
    if (italicFont == null) {
      FontData data = font.getFontData()[0];

      italicFont =
          new Font(
              Display.getDefault(), new FontData(data.getName(), data.getHeight(), SWT.ITALIC));
    }

    return italicFont;
  }
예제 #21
0
  public TagLabel(Composite parent, int style, String tagName) {
    super(parent, style);
    if (tagName == null || tagName.length() == 0) {
      throw new IllegalArgumentException("tag name is empty");
    }
    this.tagName = tagName;
    GridLayout gl = new GridLayout(2, false);
    GUIUtil.resetGridLayout(gl);
    super.setLayout(gl);

    final CLabel cross = new CLabel(this, 0);
    cross.setText("×");
    GridData data = new GridData(SWT.LEFT, SWT.TOP, false, true);
    cross.setLayoutData(data);
    data = new GridData(SWT.RIGHT, SWT.TOP, true, true);
    CLabel tagText = new CLabel(this, 0);
    tagText.setText(tagName);

    plainFont = cross.getFont();
    FontData fd = plainFont.getFontData()[0];
    boldFont = new Font(cross.getDisplay(), fd.getName(), fd.getHeight(), SWT.BOLD);
    cross.addListener(
        SWT.MouseEnter,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            cross.setFont(boldFont);
            cross.setCursor(handCursor);
          }
        });
    cross.addListener(
        SWT.MouseExit,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            cross.setFont(plainFont);
            cross.setCursor(defaultCursor);
          }
        });
    cross.addListener(
        SWT.MouseDown,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            if (delegate != null) {
              delegate.tagLabelClicked(TagLabel.this);
            }
          }
        });
  }
예제 #22
0
    @Override
    protected void initialize(ColumnViewer viewer, ViewerColumn column) {
      super.initialize(viewer, column);

      Font font = viewer.getControl().getFont();

      if (font != null) {
        FontData data = font.getFontData()[0];

        boldFont = new Font(font.getDevice(), data.getName(), data.getHeight(), SWT.BOLD);
      }
    }
  /** @generated */
  public Node createAttribute_3001(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Shape node = NotationFactory.eINSTANCE.createShape();
    node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
    node.setType(
        edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
            .NECSIS14_ClassDiagramVisualIDRegistry.getType(
            edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.AttributeEditPart
                .VISUAL_ID));
    ViewUtil.insertChildView(containerView, node, index, persisted);
    node.setElement(domainElement);
    // initializeFromPreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();

    org.eclipse.swt.graphics.RGB lineRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getLineStyle_LineColor(),
        FigureUtilities.RGBToInteger(lineRGB));
    FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (nodeFontStyle != null) {
      FontData fontData =
          PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
      nodeFontStyle.setFontName(fontData.getName());
      nodeFontStyle.setFontHeight(fontData.getHeight());
      nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
      org.eclipse.swt.graphics.RGB fontRGB =
          PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
      nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
    org.eclipse.swt.graphics.RGB fillRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getFillStyle_FillColor(),
        FigureUtilities.RGBToInteger(fillRGB));
    Node label5001 =
        createLabel(
            node,
            edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
                .NECSIS14_ClassDiagramVisualIDRegistry.getType(
                edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
                    .AttributeNameEditPart.VISUAL_ID));
    return node;
  }
예제 #24
0
  public static void initFormText(FormText formText) {

    formText.setWhitespaceNormalized(false);

    Font formTextFont = formText.getFont();
    FontData formTextFontData = formTextFont.getFontData()[0];

    FontData h1FontData =
        new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 5, SWT.BOLD);
    final Font h1Font = new Font(formTextFont.getDevice(), h1FontData);
    formText.setFont(FONT_H1_KEY, h1Font);

    FontData h3FontData =
        new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 3, SWT.BOLD);
    final Font h3Font = new Font(formTextFont.getDevice(), h3FontData);
    formText.setFont(FONT_H3_KEY, h3Font);

    Font codeFont = JFaceResources.getTextFont();
    formText.setFont(FONT_CODE_KEY, codeFont);

    formText.addDisposeListener(
        new DisposeListener() {

          @Override
          public void widgetDisposed(DisposeEvent e) {
            h1Font.dispose();
            h3Font.dispose();
          }
        });

    // Set fontKeySet = JFaceResources.getFontRegistry().getKeySet();
    // if (fontKeySet != null) {
    // for (Object fontKey : fontKeySet) {
    // System.out.println(fontKey);
    // }
    // }

  }
예제 #25
0
  /** @generated */
  public Node createStakeHolder_2011(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Shape node = NotationFactory.eINSTANCE.createShape();
    node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
    node.setType(RdalVisualIDRegistry.getType(StakeHolderEditPart.VISUAL_ID));
    ViewUtil.insertChildView(containerView, node, index, persisted);
    node.setElement(domainElement);
    stampShortcut(containerView, node);
    // initializeFromPreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();

    org.eclipse.swt.graphics.RGB lineRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getLineStyle_LineColor(),
        FigureUtilities.RGBToInteger(lineRGB));
    FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (nodeFontStyle != null) {
      FontData fontData =
          PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
      nodeFontStyle.setFontName(fontData.getName());
      nodeFontStyle.setFontHeight(fontData.getHeight());
      nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
      org.eclipse.swt.graphics.RGB fontRGB =
          PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
      nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
    org.eclipse.swt.graphics.RGB fillRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getFillStyle_FillColor(),
        FigureUtilities.RGBToInteger(fillRGB));
    Node label5018 =
        createLabel(node, RdalVisualIDRegistry.getType(StakeHolderNameEditPart.VISUAL_ID));
    label5018.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
    Location location5018 = (Location) label5018.getLayoutConstraint();
    location5018.setX(0);
    location5018.setY(5);
    return node;
  }
예제 #26
0
 @Inject
 void trackFontSize(
     @Preference(
             nodePath = RelationsConstants.PREFERENCE_NODE,
             value = RelationsConstants.KEY_TEXT_FONT_SIZE)
         final int inFontSize) {
   if (textWidget == null || textWidget.isDisposed()) {
     fontSizeToUse = inFontSize;
   } else {
     final FontData lData = textWidget.getFont().getFontData()[0];
     if (inFontSize != lData.getHeight()) {
       lData.setHeight(inFontSize);
       final Font lNewFont = new Font(Display.getCurrent(), lData);
       textWidget.setFont(lNewFont);
     }
   }
 }
예제 #27
0
 /** @generated */
 public Node createRequirementsGroup_2007(
     EObject domainElement,
     View containerView,
     int index,
     boolean persisted,
     PreferencesHint preferencesHint) {
   Node node = NotationFactory.eINSTANCE.createNode();
   node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
   node.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
   node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle());
   node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
   node.setType(RdalVisualIDRegistry.getType(RequirementsGroupEditPart.VISUAL_ID));
   ViewUtil.insertChildView(containerView, node, index, persisted);
   node.setElement(domainElement);
   stampShortcut(containerView, node);
   // initializeFromPreferences
   final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
   FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE);
   if (nodeFontStyle != null) {
     FontData fontData =
         PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
     nodeFontStyle.setFontName(fontData.getName());
     nodeFontStyle.setFontHeight(fontData.getHeight());
     nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
     nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
     org.eclipse.swt.graphics.RGB fontRGB =
         PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
     nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
   }
   org.eclipse.swt.graphics.RGB fillRGB =
       PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR);
   ViewUtil.setStructuralFeatureValue(
       node,
       NotationPackage.eINSTANCE.getFillStyle_FillColor(),
       FigureUtilities.RGBToInteger(fillRGB));
   Node label5013 =
       createLabel(node, RdalVisualIDRegistry.getType(RequirementsGroupNameEditPart.VISUAL_ID));
   createCompartment(
       node,
       RdalVisualIDRegistry.getType(RequirementsGroupRequirementsCompartmentEditPart.VISUAL_ID),
       true,
       false,
       false,
       false);
   return node;
 }
  /**
   * Clients are expected to override this method if they require a custom layout with various
   * composites
   *
   * @param parent
   * @param top
   */
  protected void addDeploymentLocationControls(Composite parent, Control top) {
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    Label l1 = toolkit.createLabel(parent, Messages.EditorDeploymentPageWarning);
    FontData fontData = l1.getFont().getFontData()[0];
    Font font =
        new Font(
            parent.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
    l1.setFont(font);

    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 5);
    fd.top = top == null ? new FormAttachment(0, 5) : new FormAttachment(top, 5);
    fd.right = new FormAttachment(100, -5);
    l1.setLayoutData(fd);

    errorImage = toolkit.createLabel(parent, "");
    fd = new FormData();
    fd.top = new FormAttachment(l1, 5);
    fd.left = new FormAttachment(0, 0);
    errorImage.setLayoutData(fd);

    errorLabel = toolkit.createLabel(parent, "", SWT.WRAP);
    fd = new FormData();
    fd.top = new FormAttachment(l1, 5);
    fd.left = new FormAttachment(0, 20);
    fd.right = new FormAttachment(0, 600);
    errorLabel.setLayoutData(fd);

    // First section is deployment mode (server / custom / metadata) etc.
    standardOptions = createServerDeploymentOptions(parent);
    standardOptions.setLayoutData(UIUtil.createFormData2(errorLabel, 5, null, 0, 0, 5, 100, -5));

    // Simply create a composite to show the per-module customizations
    perModuleOptions = createModuleDeploymentOptions(parent);
    fd = new FormData();
    fd.left = new FormAttachment(0, 5);
    fd.top = new FormAttachment(standardOptions, 5);
    fd.right = new FormAttachment(100, -5);
    fd.bottom = new FormAttachment(100, -5);
    perModuleOptions.setLayoutData(fd);
  }
예제 #29
0
  /**
   * This method obtains the fonts that are being used by the figure at its zoom level.
   *
   * @param gep the associated <code>GraphicalEditPart</code> of the figure
   * @param actualFont font being used by the figure
   * @param display
   * @return <code>actualFont</code> if zoom level is 1.0 (or when there's an error), new Font
   *     otherwise.
   */
  private Font getZoomLevelFont(Font actualFont, Display display) {
    Object zoom = getEditPart().getViewer().getProperty(ZoomManager.class.toString());

    if (zoom != null) {
      double zoomLevel = ((ZoomManager) zoom).getZoom();

      if (zoomLevel == 1.0f) return actualFont;

      FontData[] fd = new FontData[actualFont.getFontData().length];
      FontData tempFD = null;

      for (int i = 0; i < fd.length; i++) {
        tempFD = actualFont.getFontData()[i];

        fd[i] =
            new FontData(
                tempFD.getName(), (int) (zoomLevel * tempFD.getHeight()), tempFD.getStyle());
      }

      try {
        FontDescriptor fontDescriptor = FontDescriptor.createFrom(fd);
        cachedFontDescriptors.add(fontDescriptor);
        return getResourceManager().createFont(fontDescriptor);
      } catch (DeviceResourceException e) {
        Trace.catching(
            DiagramUIPlugin.getInstance(),
            DiagramUIDebugOptions.EXCEPTIONS_CATCHING,
            getClass(),
            "getZoomLevelFonts",
            e); //$NON-NLS-1$
        Log.error(
            DiagramUIPlugin.getInstance(),
            DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
            "getZoomLevelFonts",
            e); //$NON-NLS-1$

        return actualFont;
      }
    } else return actualFont;
  }
  /**
   * initialize the font for a graphical element
   *
   * @param view the element to initialize
   * @param store the preference store
   * @param elementName the name to the element
   */
  public static void initFontStyleFromPrefs(
      View view, final IPreferenceStore store, String elementName) {
    if (!usePreferenceInitializer(view)) {
      return;
    }

    String fontConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.FONT);
    String fontColorConstant =
        getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_FONT);

    FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (viewFontStyle != null) {
      FontData fontData = PreferenceConverter.getFontData(store, fontConstant);
      viewFontStyle.setFontName(fontData.getName());
      viewFontStyle.setFontHeight(fontData.getHeight());
      viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);

      org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant);
      viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
  }