private FontData createFontDataFromNormal() {
   FontData normalData = NORMAL.getFontData()[0];
   FontData result = new FontData();
   result.setName(normalData.getName());
   result.height = normalData.height;
   return result;
 }
示例#2
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;
  }
  /**
   * 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;
  }
示例#4
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);
  }
示例#5
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 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;
 }
  /** @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
  private static void init() {
    BOLD = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
    ITALIC = JFaceResources.getFontRegistry().getItalic(JFaceResources.DEFAULT_FONT);
    BOLD_ITALIC =
        new Font(
            Display.getCurrent(), getModifiedFontData(ITALIC.getFontData(), SWT.BOLD | SWT.ITALIC));

    Font defaultFont = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
    FontData[] defaultData = defaultFont.getFontData();
    if (defaultData != null && defaultData.length == 1) {
      FontData data =
          new FontData(
              defaultData[0].getName(), defaultData[0].getHeight(), defaultData[0].getStyle());

      if ("win32".equals(SWT.getPlatform())) { // $NON-NLS-1$
        // NOTE: Windows only, for: data.data.lfStrikeOut = 1;
        try {
          Field dataField = data.getClass().getDeclaredField("data"); // $NON-NLS-1$
          Object dataObject = dataField.get(data);
          Class<?> clazz = dataObject.getClass().getSuperclass();
          Field strikeOutFiled = clazz.getDeclaredField("lfStrikeOut"); // $NON-NLS-1$
          strikeOutFiled.set(dataObject, (byte) 1);
          CommonFonts.STRIKETHROUGH = new Font(Display.getCurrent(), data);
        } catch (Throwable t) {
          // ignore
        }
      }
    }
    if (CommonFonts.STRIKETHROUGH == null) {
      CommonFonts.HAS_STRIKETHROUGH = false;
      CommonFonts.STRIKETHROUGH = defaultFont;
    } else {
      CommonFonts.HAS_STRIKETHROUGH = true;
    }
  }
  private java.awt.Font getSelectedFont() {
    // Always use a large font for the rendering, even though user is typically
    // picking small font sizes in the font chooser
    // int dpi = mFontButton.getDisplay().getDPI().y;
    // int height = (int) Math.round(fontData.getHeight() * dpi / 72.0);
    int fontHeight = new TextRenderUtil.Options().fontSize;

    if (mFontButton.getData() == null) {
      // The user has not yet picked a font; look up the default font to use
      // (Helvetica Bold, not whatever font happened to be used for button widgets
      // in SWT on this platform)
      return new java.awt.Font("Helvetica", java.awt.Font.BOLD, fontHeight); // $NON-NLS-1$
    }

    Font font = mFontButton.getFont();
    FontData fontData = font.getFontData()[0];

    int awtStyle = java.awt.Font.PLAIN;
    int swtStyle = fontData.getStyle();

    if ((swtStyle & SWT.ITALIC) != 0) {
      awtStyle |= java.awt.Font.ITALIC;
    }
    if ((swtStyle & SWT.BOLD) != 0) {
      awtStyle = java.awt.Font.BOLD;
    }

    return new java.awt.Font(fontData.getName(), awtStyle, fontHeight);
  }
 public static void main(String[] args) {
   final Display display = new Display();
   final Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER);
   styledText.setText(text);
   FontData data = display.getSystemFont().getFontData()[0];
   Font font = new Font(display, data.getName(), 16, SWT.BOLD);
   styledText.setFont(font);
   styledText.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
   styledText.addListener(
       SWT.Resize,
       new Listener() {
         public void handleEvent(Event event) {
           Rectangle rect = styledText.getClientArea();
           Image newImage = new Image(display, 1, Math.max(1, rect.height));
           GC gc = new GC(newImage);
           gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
           gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
           gc.fillGradientRectangle(rect.x, rect.y, 1, rect.height, true);
           gc.dispose();
           styledText.setBackgroundImage(newImage);
           if (oldImage != null) oldImage.dispose();
           oldImage = newImage;
         }
       });
   shell.setSize(700, 400);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   if (oldImage != null) oldImage.dispose();
   font.dispose();
   display.dispose();
 }
 /** 사용자 폰트를 설정합니다. */
 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());
   }
 }
示例#12
0
 /**
  * Styles a font.
  *
  * @param font
  * @return styled font data
  */
 public static FontData[] styleFont(Font font, int fontStyle) {
   FontData[] datas = font.getFontData();
   for (FontData data : datas) {
     data.setStyle(data.getStyle() | fontStyle);
   }
   return datas;
 }
  /**
   * 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();
  }
  protected int addLabelBox(
      String text,
      int xPos,
      int yPos,
      int labelWidth,
      int labelHeight,
      int fontSize,
      float scaleFactor) {
    Box labelBox = ModelFactory.eINSTANCE.createBox();
    labelBox.setSize(new Dimension(labelWidth, labelHeight));
    labelBox.setLocation(new Point(xPos, yPos));
    LabelBoxPrinter labelBoxPrinter = new LabelBoxPrinter(scaleFactor);
    labelBox.setBoxPrinter(labelBoxPrinter);

    labelBox.setID("Standard Label"); // $NON-NLS-1$
    labelBoxPrinter.setText(text);
    labelBoxPrinter.setHorizontalAlignment(SWT.CENTER);
    try {
      FontData data = Display.getDefault().getSystemFont().getFontData()[0];

      data.setHeight(fontSize);
      data.setStyle(SWT.BOLD);

      Font font = AWTSWTImageUtils.swtFontToAwt(data);
      labelBoxPrinter.setFont(font);

    } catch (Exception e) {
      // oh well don't have that font type
    }
    boxes.add(labelBox);
    return labelHeight;
  }
示例#15
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;
  }
示例#16
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");
 }
示例#17
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;
  }
示例#18
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;
   }
 }
 private String[] getScalableFonts() {
   FontData[] fontData = Display.getCurrent().getFontList(null, true);
   Set<String> fontSet = new HashSet<String>();
   for (FontData fd : fontData) {
     fontSet.add(fd.getName());
   }
   Set<String> fontCache = new TreeSet<String>((new FontCache()).getAvailableFonts());
   fontCache.retainAll(fontSet);
   return (String[]) fontCache.toArray(new String[0]);
 }
示例#20
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();
 }
示例#21
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>");
 }
 /**
  * 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;
  }
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
  */
 protected Object openDialogBox(Control cellEditorWindow) {
   FontDialog dialog = new FontDialog(cellEditorWindow.getShell());
   dialog.setText(MessageUtil.getString("FontDialogTitle"));
   if (getValue() != null) {
     FontData[] oldFont = new FontData[] {new FontData(getValue().toString(), 12, SWT.NORMAL)};
     dialog.setFontList(oldFont);
   }
   FontData fontData = dialog.open();
   if (fontData != null) return fontData.getName();
   return "";
 }
示例#25
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;
  }
 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;
 }
示例#27
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);
 }
示例#28
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);
            }
          }
        });
  }
示例#29
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);
      }
    }
示例#30
0
 private Font getMergeTreeFont() {
   if (mergeTreeFont != null) {
     // mergeTreeFont.dispose();
   }
   FontData systemFontData = Display.getDefault().getSystemFont().getFontData()[0];
   int height =
       MergePlugin.getDefault()
           .getPreferenceStore()
           .getInt(MergeEditorPreferencePage.P_MERGE_EDITOR_FONT_SIZE);
   mergeTreeFont =
       FontUtils.getStyledFont(null, systemFontData.getName(), height, systemFontData.getStyle());
   return mergeTreeFont;
 }