コード例 #1
0
 private static void addFragments(
     BidiRun run,
     char[] text,
     int start,
     int end,
     int fontStyle,
     FontPreferences fontPreferences,
     FontRenderContext fontRenderContext,
     @Nullable TabFragment tabFragment) {
   Font currentFont = null;
   int currentIndex = start;
   for (int i = start; i < end; i++) {
     char c = text[i];
     if (c == '\t' && tabFragment != null) {
       assert run.level == 0;
       addTextFragmentIfNeeded(
           run, text, currentIndex, i, currentFont, fontRenderContext, run.isRtl());
       run.fragments.add(tabFragment);
       currentFont = null;
       currentIndex = i + 1;
     } else {
       Font font =
           ComplementaryFontsRegistry.getFontAbleToDisplay(c, fontStyle, fontPreferences)
               .getFont();
       if (!font.equals(currentFont)) {
         addTextFragmentIfNeeded(
             run, text, currentIndex, i, currentFont, fontRenderContext, run.isRtl());
         currentFont = font;
         currentIndex = i;
       }
     }
   }
   addTextFragmentIfNeeded(
       run, text, currentIndex, end, currentFont, fontRenderContext, run.isRtl());
 }
コード例 #2
0
ファイル: TextLine.java プロジェクト: mytnyk/PRIAMUS
 /**
  * Set the Font to use with the class
  *
  * @param f Font
  */
 public void setFont(Font f) {
   font = f;
   fontname = f.getName();
   fontstyle = f.getStyle();
   fontsize = f.getSize();
   parse = true;
 }
コード例 #3
0
 private static void fillStyledFontMap() {
   Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
   for (Font font : allFonts) {
     String name = font.getName();
     Integer style = null;
     if (!SystemInfo.isAppleJvm) {
       style =
           FONT_NAME_TO_STYLE.get(
               name); // workaround with explicit fontName->style mapping doesn't work on Apple JVM
     }
     if (style == null) {
       if (!Patches.JDK_MAC_FONT_STYLE_BUG) continue;
       style = getFontStyle(name);
     }
     if (style != Font.PLAIN) {
       String familyName = font.getFamily();
       Pair<String, Integer>[] entry = ourStyledFontMap.get(familyName);
       if (entry == null) {
         //noinspection unchecked
         entry = new Pair[4];
         for (int i = 1; i < 4; i++) {
           entry[i] = Pair.create(familyName, i);
         }
         ourStyledFontMap.put(familyName, entry);
       }
       entry[style] = Pair.create(name, Font.PLAIN);
     }
   }
 }
コード例 #4
0
ファイル: StringLabel.java プロジェクト: adoGT/prismFDCTMC
  public void workOutMinsAndMaxs() {
    StringTokenizer tokens = new StringTokenizer(getRenderString(), "\n");

    int noLines = tokens.countTokens();

    double height = (theFont.getSize2D() * noLines) + 5;
    double width = 0;

    while (tokens.hasMoreTokens()) {
      double l = theFont.getSize2D() * tokens.nextToken().length() * (5.0 / 8.0);
      if (l > width) width = l;
    }

    double parX;
    double parY;
    if (parent instanceof State) {
      parX = ((State) parent).getX();
      parY = ((State) parent).getY();
    } else if (parent instanceof Transition) {
      parX = ((Transition) parent).getMiddle().getX(); // dummy
      parY = ((Transition) parent).getMiddle().getY(); // dummy
    } else {
      parX = 0;
      parY = 0;
    }

    minX = parX + offsetX - 5;
    minY = parY + offsetY - 25;

    maxX = parX + width + offsetX + 5;
    maxY = parY + height + offsetY - 5;
  }
コード例 #5
0
ファイル: StringLabel.java プロジェクト: adoGT/prismFDCTMC
  public Rectangle2D getBounds2D() {
    StringTokenizer tokens = new StringTokenizer(getRenderString(), "\n");

    int noLines = tokens.countTokens();

    double height = (theFont.getSize2D() * noLines) + 5;
    double width = 0;

    while (tokens.hasMoreTokens()) {
      double l = theFont.getSize2D() * tokens.nextToken().length() * (5.0 / 8.0);
      if (l > width) width = l;
    }

    double parX;
    double parY;
    if (parent instanceof State) {
      parX = ((State) parent).getX();
      parY = ((State) parent).getY();
    } else if (parent instanceof Transition) {
      parX = ((Transition) parent).getMiddle().getX(); // dummy
      parY = ((Transition) parent).getMiddle().getY(); // dummy
    } else {
      parX = 0;
      parY = 0;
    }

    double mx = parX + offsetX;
    double my = parY + offsetY - 10;

    double tx = parX + width + offsetX;
    double ty = parY + height + offsetY - 10;

    return new Rectangle2D.Double(mx, my, tx - mx, ty - my);
  }
コード例 #6
0
  public ExtendedTextField() {
    setFullScreenMode(true);

    setCommandListener(this);

    exit = new Command("Exit", Command.EXIT, 1);
    open = new Command("Open", Command.ITEM, 1);
    newFile = new Command("New", Command.ITEM, 2);
    save = new Command("Save", Command.ITEM, 3);
    saveAs = new Command("Save As", Command.ITEM, 4);
    eval = new Command("Eval", Command.ITEM, 5);
    output = new Command("Output", Command.ITEM, 6);
    cls = new Command("Clear", Command.ITEM, 7);

    addCommand(exit);
    addCommand(newFile);
    addCommand(open);
    addCommand(save);
    addCommand(saveAs);
    addCommand(eval);
    addCommand(output);
    addCommand(cls);

    new Thread(this).start();

    // TODO: change font size?
    inputFont = Font.getDefaultFont();
    inputWidth = getWidth();
    inputHeight = inputFont.getHeight();
    linesOnScreen = getHeight() / inputHeight;

    addNewLine(0);
  }
コード例 #7
0
 private static Font findFont(String name) {
   for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
     if (font.getName().equals(name)) {
       return font;
     }
   }
   return null;
 }
コード例 #8
0
ファイル: TextLine.java プロジェクト: mytnyk/PRIAMUS
 /**
  * Instantiate the class
  *
  * @param s String to parse.
  * @param f Font to use.
  */
 public TextLine(String s, Font f) {
   this(s);
   font = f;
   if (font == null) return;
   fontname = f.getName();
   fontstyle = f.getStyle();
   fontsize = f.getSize();
 }
コード例 #9
0
 @Override
 public Font getFont(EditorFontType key) {
   if (UISettings.getInstance().PRESENTATION_MODE) {
     final Font font = myFonts.get(key);
     return new Font(
         font.getName(), font.getStyle(), UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
   }
   return myFonts.get(key);
 }
コード例 #10
0
ファイル: TextLine.java プロジェクト: mytnyk/PRIAMUS
  /**
   * Instantiate the class
   *
   * @param f Font to use.
   * @param c Color to use
   * @param j Justification
   */
  public TextLine(Font f, Color c, int j) {
    font = f;
    color = c;
    justification = j;

    if (font == null) return;
    fontname = f.getName();
    fontstyle = f.getStyle();
    fontsize = f.getSize();
  }
コード例 #11
0
ファイル: HyperSearchResults.java プロジェクト: SELab/jEdit
 // {{{ parseHighlightStyle()
 SyntaxStyle parseHighlightStyle(String style) {
   Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font");
   SyntaxStyle s;
   try {
     s = SyntaxUtilities.parseStyle(style, f.getFamily(), f.getSize(), true, null);
   } catch (Exception e) {
     style = "color:#000000";
     s = SyntaxUtilities.parseStyle(style, f.getFamily(), f.getSize(), true);
   }
   return s;
 } // }}}
  @Override
  public Font getTerminalFont() {
    Font normalFont = Font.decode(getFontName());

    if (normalFont == null) {
      normalFont = super.getTerminalFont();
    }

    normalFont = normalFont.deriveFont(getTerminalFontSize());

    return normalFont;
  }
コード例 #13
0
ファイル: DrawbotGUI.java プロジェクト: bertbalcaen/DrawBot
  public Container CreateContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // the log panel
    log = new JTextPane();
    log.setEditable(false);
    log.setBackground(Color.BLACK);
    logPane = new JScrollPane(log);
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    log.setEditorKit(kit);
    log.setDocument(doc);
    DefaultCaret c = (DefaultCaret) log.getCaret();
    c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ClearLog();

    // the preview panel
    previewPane = new DrawPanel();
    previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right);

    // status bar
    statusBar = new StatusBar();
    Font f = statusBar.getFont();
    statusBar.setFont(f.deriveFont(Font.BOLD, 15));
    Dimension d = statusBar.getMinimumSize();
    d.setSize(d.getWidth(), d.getHeight() + 30);
    statusBar.setMinimumSize(d);

    // layout
    Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT);
    split.add(previewPane);
    split.add(logPane);
    split.setDividerSize(8);

    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(split, BorderLayout.CENTER);

    // open the file
    if (recentFiles[0].length() > 0) {
      OpenFileOnDemand(recentFiles[0]);
    }

    // connect to the last port
    ListSerialPorts();
    if (Arrays.asList(portsDetected).contains(recentPort)) {
      OpenPort(recentPort);
    }

    return contentPane;
  }
コード例 #14
0
  @Override
  public UIDefaults getDefaults() {
    try {
      final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
      superMethod.setAccessible(true);
      final UIDefaults metalDefaults = (UIDefaults) superMethod.invoke(new MetalLookAndFeel());

      final UIDefaults defaults = (UIDefaults) superMethod.invoke(base);
      if (SystemInfo.isLinux) {
        if (!Registry.is("darcula.use.native.fonts.on.linux")) {
          Font font = findFont("DejaVu Sans");
          if (font != null) {
            for (Object key : defaults.keySet()) {
              if (key instanceof String && ((String) key).endsWith(".font")) {
                defaults.put(key, new FontUIResource(font.deriveFont(13f)));
              }
            }
          }
        } else if (Arrays.asList("CN", "JP", "KR", "TW")
            .contains(Locale.getDefault().getCountry())) {
          for (Object key : defaults.keySet()) {
            if (key instanceof String && ((String) key).endsWith(".font")) {
              final Font font = defaults.getFont(key);
              if (font != null) {
                defaults.put(key, new FontUIResource("Dialog", font.getStyle(), font.getSize()));
              }
            }
          }
        }
      }

      LafManagerImpl.initInputMapDefaults(defaults);
      initIdeaDefaults(defaults);
      patchStyledEditorKit(defaults);
      patchComboBox(metalDefaults, defaults);
      defaults.remove("Spinner.arrowButtonBorder");
      defaults.put("Spinner.arrowButtonSize", JBUI.size(16, 5).asUIResource());
      MetalLookAndFeel.setCurrentTheme(createMetalTheme());
      if (SystemInfo.isWindows && Registry.is("ide.win.frame.decoration")) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
      }
      if (SystemInfo.isLinux && JBUI.isHiDPI()) {
        applySystemFonts(defaults);
      }
      defaults.put("EditorPane.font", defaults.getFont("TextField.font"));
      return defaults;
    } catch (Exception e) {
      log(e);
    }
    return super.getDefaults();
  }
コード例 #15
0
  private void _applyFontStyleForSelection(Font font) {
    StyledDocument doc = mTextEditor.getStyledDocument();
    MutableAttributeSet attrs = mTextEditor.getInputAttributes();
    StyleConstants.setFontFamily(attrs, font.getFamily());
    StyleConstants.setFontSize(attrs, font.getSize());
    StyleConstants.setBold(attrs, ((font.getStyle() & Font.BOLD) != 0));
    StyleConstants.setItalic(attrs, ((font.getStyle() & Font.ITALIC) != 0));
    StyleConstants.setUnderline(attrs, ((font.getStyle() & Font.CENTER_BASELINE) != 0));

    int start = mTextEditor.getSelectionStart();
    int end = mTextEditor.getSelectionEnd();
    doc.setCharacterAttributes(start, (end - start), attrs, false);
  }
コード例 #16
0
ファイル: TextLine.java プロジェクト: mytnyk/PRIAMUS
  /**
   * Copy the state of the parsed Textline into the existing object.
   *
   * @param t The TextLine to get the state information from.
   */
  public void copyState(TextLine t) {
    if (t == null) return;

    font = t.getFont();
    color = t.getColor();
    justification = t.getJustification();

    if (font == null) return;
    fontname = font.getName();
    fontstyle = font.getStyle();
    fontsize = font.getSize();

    parse = true;
  }
コード例 #17
0
  /**
   * Gets the FontMetrics object for the supplied font. This method caches font metrics to ensure
   * native fonts are not loaded twice for the same font.
   */
  static synchronized QtFontMetrics getFontMetrics(Font font, boolean backwardCompat) {

    /* See if metrics has been stored in font already. */

    QtFontMetrics fm = (QtFontMetrics) font.metrics;

    if (fm == null) {
      boolean strikethrough = false, underline = false;

      /* See if a font metrics of the same native name and size has already been loaded.
      If it has then we use that one. */

      String nativeName = (String) fontNameMap.get(font.name.toLowerCase());

      if (nativeName == null) nativeName = (String) fontNameMap.get("default");

      String key = nativeName + "." + font.style + "." + font.size;

      if (!backwardCompat) {
        Map fa = font.getAttributes();
        Object obj;

        if ((obj = fa.get(TextAttribute.STRIKETHROUGH)) != null) {
          if (obj.equals(TextAttribute.STRIKETHROUGH_ON)) {
            key += ".s";
            strikethrough = true;
          }
        }

        if ((obj = fa.get(TextAttribute.UNDERLINE)) != null) {
          if (obj.equals(TextAttribute.UNDERLINE_ON)) {
            key += ".u";
            underline = true;
          }
        }
      }

      fm = (QtFontMetrics) fontMetricsMap.get(key);

      if (fm == null) {
        fontMetricsMap.put(
            key, fm = new QtFontMetrics(font, nativeName, font.style, strikethrough, underline));
      }

      font.metrics = fm;
    }

    return fm;
  }
コード例 #18
0
  public TabbedEditor(org.colos.ejs.osejs.Osejs _ejs, String _type, String _header) {
    ejs = _ejs;
    defaultType = _type;
    defaultHeader = _header;
    defaultString = new String(res.getString(defaultHeader + ".Page"));

    MyActionListener al = new MyActionListener();

    popupMenu = new PopupMenu();
    customMenuItems(al); // Creates the top menu items
    // common menu items
    copyPage = createMenuItem("copyPage", defaultHeader, al);
    upPage = createMenuItem("upPage", defaultHeader, al);
    dnPage = createMenuItem("dnPage", defaultHeader, al);
    renamePage = createMenuItem("renamePage", defaultHeader, al);
    popupMenu.addSeparator();
    togglePage = createMenuItem("togglePage", defaultHeader, al);
    removePage = createMenuItem("removePage", defaultHeader, al);

    JPanel firstPanel = createFirstPanel();

    tabbedPanel = new JTabbedPane();
    tabbedPanel.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    tabbedPanel.add(popupMenu);
    // tabbedPanel.setPreferredSize (res.getDimension("TabbedEditor.PreferredSize"));
    tabbedPanel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mousePressed(java.awt.event.MouseEvent evt) {
            if (OSPRuntime.isPopupTrigger(evt)) // SwingUtilities.isRightMouseButton(evt))
            showMenu(evt.getComponent(), evt.getX(), evt.getY());
          }
        });
    cardLayout = new CardLayout();
    finalPanel = new JPanel(cardLayout);
    finalPanel.add(tabbedPanel, "TabbedPanel");
    finalPanel.add(firstPanel, "FirstPanel");
    setFont(finalPanel.getFont());

    Font font = InterfaceUtils.font(null, res.getString("Editor.TitleFont"));
    addPageMI.setFont(font);
    copyPage.setFont(font);
    upPage.setFont(font);
    dnPage.setFont(font);
    togglePage.setFont(font);
    removePage.setFont(font);
    renamePage.setFont(font);
    myFont = font.deriveFont(Font.PLAIN);
    showFirstPage();
  }
コード例 #19
0
ファイル: TextLine.java プロジェクト: mytnyk/PRIAMUS
  /**
   * @param f Font
   * @return The script font version of the parsed font using the script_fraction variable.
   */
  public Font getScriptFont(Font f) {
    int size;

    if (f == null) return f;

    size = f.getSize();

    if (size <= MINIMUM_SIZE) return f;

    size = (int) ((double) (f.getSize()) * script_fraction + 0.5);

    if (size <= MINIMUM_SIZE) return f;

    return new Font(f.getName(), f.getStyle(), size);
  }
コード例 #20
0
  void displayCharacterMap(Graphics g) {
    if (currentChars != null) {
      g.setColor(0xffffff);
      g.fillRect(0, getHeight() - inputHeight - 2, getWidth(), inputHeight + 2);
      g.setColor(0x000000);
      g.drawLine(0, getHeight() - inputHeight - 2, getWidth(), getHeight() - inputHeight - 2);
      for (int i = 0; i < currentChars.length; i++) {
        char ch = currentChars[i];
        if (isUppercase) {
          ch = String.valueOf(currentChars[i]).toUpperCase().charAt(0);
        }

        // TODO: if i*12 > getWidth() ?

        g.drawChar(ch, i * 12, getHeight() - inputHeight, Graphics.LEFT | Graphics.TOP);
        if (currentChars[currentKeyStep] == currentChars[i]) {
          g.drawRect(
              i * 12 - 2,
              getHeight() - inputHeight - 2,
              inputFont.charWidth(ch) + 4,
              inputHeight + 4);
        }
      }
    }
  }
コード例 #21
0
  public int getVWidth() {
    // g.setColor(0);
    if (width > 0) return width; // cached

    int w = 0;
    int imgWidth = imgWidth();

    for (int index = 0; index < elementCount; index++) {
      Object ob = elementData[index];
      if (ob != null) {

        if (ob instanceof String) {
          // string element
          w += font.stringWidth((String) ob);
        } else if ((ob instanceof Integer) && imageList != null) {
          // image element or color
          int i = (((Integer) ob).intValue());
          switch (i & 0xff000000) {
            case IMAGE:
              w += imgWidth;
              break;
          }
        } // Integer
      } // if ob!=null
    } // for
    return width = w;
  }
コード例 #22
0
ファイル: ScoreParser.java プロジェクト: emtwo/piano
  private void addFont(String fontKey, String fontName, float scale) {
    try {
      fontName = fontName.toLowerCase();

      FileInputStream stream = new FileInputStream("data/fonts/ttf/" + fontName + ".ttf");

      Font f = Font.createFont(Font.TRUETYPE_FONT, stream);
      f = f.deriveFont(scale);

      fonts.put(fontKey, f);
      stream.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #23
0
 /**
  * Returns the size style of a specified component.
  *
  * @return REGULAR, SMALL or MINI.
  */
 private int getSizeStyle(Component c) {
   // Aqua components have a different style depending on the
   // font size used.
   // 13 Point = Regular
   // 11 Point = Small
   //  9 Point = Mini
   if (c == null) {
     return REGULAR;
   }
   Font font = c.getFont();
   if (font == null) {
     return REGULAR;
   }
   int fontSize = font.getSize();
   return (fontSize >= 13) ? REGULAR : ((fontSize > 9) ? SMALL : MINI);
 }
コード例 #24
0
 void drawRoiLabel(Graphics g, int index, Roi roi) {
   Rectangle r = roi.getBounds();
   int x = screenX(r.x);
   int y = screenY(r.y);
   double mag = getMagnification();
   int width = (int) (r.width * mag);
   int height = (int) (r.height * mag);
   int size = width > 40 && height > 40 ? 12 : 9;
   if (font != null) {
     g.setFont(font);
     size = font.getSize();
   } else if (size == 12) g.setFont(largeFont);
   else g.setFont(smallFont);
   boolean drawingList = index >= LIST_OFFSET;
   if (drawingList) index -= LIST_OFFSET;
   String label = "" + (index + 1);
   if (drawNames && roi.getName() != null) label = roi.getName();
   FontMetrics metrics = g.getFontMetrics();
   int w = metrics.stringWidth(label);
   x = x + width / 2 - w / 2;
   y = y + height / 2 + Math.max(size / 2, 6);
   int h = metrics.getAscent() + metrics.getDescent();
   if (bgColor != null) {
     g.setColor(bgColor);
     g.fillRoundRect(x - 1, y - h + 2, w + 1, h - 3, 5, 5);
   }
   if (!drawingList && labelRects != null && index < labelRects.length)
     labelRects[index] = new Rectangle(x - 1, y - h + 2, w + 1, h);
   g.setColor(labelColor);
   g.drawString(label, x, y - 2);
   g.setColor(defaultColor);
 }
コード例 #25
0
 protected void initRenderingParams() {
   GraticuleRenderingParams params = new GraticuleRenderingParams();
   params.setValue(GraticuleRenderingParams.KEY_LINE_COLOR, new Color(.8f, .8f, .8f, .5f));
   params.setValue(GraticuleRenderingParams.KEY_LABEL_COLOR, new Color(1f, 1f, 1f, .8f));
   params.setValue(GraticuleRenderingParams.KEY_LABEL_FONT, Font.decode("Arial-Bold-14"));
   params.setValue(GraticuleRenderingParams.KEY_DRAW_LABELS, Boolean.TRUE);
   setRenderingParams(GRATICULE_UTM, params);
 }
コード例 #26
0
  /**
   * Set current font. Default to Plain Courier 11 if null.
   *
   * @param font new font.
   */
  public void setFont(Font font) {

    if (font != null) {
      m_localGraphicsState.setFont(font);
      if (font.getName().equals(m_psGraphicsState.getFont().getName())
          && (m_psGraphicsState.getFont().getStyle() == font.getStyle())
          && (m_psGraphicsState.getFont().getSize() == yScale(font.getSize()))) return;
      m_psGraphicsState.setFont(
          new Font(font.getName(), font.getStyle(), yScale(getFont().getSize())));
    } else {
      m_localGraphicsState.setFont(new Font("Courier", Font.PLAIN, 11));
      m_psGraphicsState.setFont(getFont());
    }

    m_printstream.println("/(" + replacePSFont(getFont().getPSName()) + ")" + " findfont");
    m_printstream.println(yScale(getFont().getSize()) + " scalefont setfont");
  }
コード例 #27
0
ファイル: BDFontMetrics.java プロジェクト: Torc/torc
 /**
  * Gets the BDFontMetrics object for the supplied font. This method caches font metrics to ensure
  * native fonts are not loaded twice for the same font.
  */
 static synchronized BDFontMetrics getFontMetrics(Font font) {
   /* See if metrics has been stored in font already. */
   BDFontMetrics fm = null;
   // BDFontMetrics fm = (BDFontMetrics)font.metrics;
   // if (fm == null) {
   /* See if a font metrics of the same native name and size has already been loaded.
   If it has then we use that one. */
   String nativeName =
       (String) fontNameMap.get(font.getName().toLowerCase() + "." + font.getStyle());
   if (nativeName == null) nativeName = (String) fontNameMap.get("default." + font.getStyle());
   String key = nativeName + "." + font.getSize();
   fm = (BDFontMetrics) fontMetricsMap.get(key);
   if (fm == null) fontMetricsMap.put(key, fm = new BDFontMetrics(font, nativeName));
   // font.metrics = fm;
   // }
   return fm;
 }
コード例 #28
0
ファイル: StringLabel.java プロジェクト: adoGT/prismFDCTMC
  /**
   * A rendering method to draw this label to the given Graphics2D object, with the additional
   * option of allowing the "long" lines to be drawn. Due to the fact that the relative drawing
   * point of a state is its x and y co-ordinates and for a Transition there is a workOutMiddle()
   * method, the relative x and y values must be supplied to this method. Usually this method will
   * be called from inside a Transition render method or a State render method.
   *
   * @param g2 the Graphics2D component upon which to draw this label.
   * @param x the x position upon which to make relative co-ordinates exact.
   * @param y the y position upon which to make relative co-ordinates exact.
   * @param longLines flag to determine whether the long version of this label should be drawn.
   */
  public void render(Graphics2D g2, double x, double y, boolean longLines) {
    intersects(new Rectangle2D.Double(0, 0, 1, 1));
    StringTokenizer tokens = new StringTokenizer(getRenderString(), "\n");
    if (selected) {
      g2.setColor(Color.green);
    } else {
      g2.setColor(theColour);
    }
    g2.setFont(theFont);
    int i = 0;
    boolean doneLong = false;
    while (tokens.hasMoreTokens()) {
      if (doneLong)
        g2.drawString(
            tokens.nextToken(),
            (float) (x + offsetX),
            (float) (y + offsetY + ((i * (theFont.getSize() + 2)))));
      else {
        if (!longLines)
          g2.drawString(
              tokens.nextToken().trim(),
              (float) (x + offsetX),
              (float) (y + offsetY + ((i * (theFont.getSize()))) + 2));
        else
          g2.drawString(
              getName() + ": " + tokens.nextToken().trim(),
              (float) (x + offsetX),
              (float) (y + offsetY + ((i * (theFont.getSize()))) + 2));
      }
      i++;
      doneLong = true;
    }

    /*if(intersects != null)
    {
        g2.setColor(Color.magenta);
        for(int j = 0; j < intersects.size(); j++)
        {
            Rectangle2D rect = (Rectangle2D)intersects.get(j);
            g2.draw(rect);
        }
    }*/

  }
コード例 #29
0
  void displayLines(Graphics g, int yStart) {
    // (1 + 2, depends on font size)

    if (isSelection && (xStartSelection != xEndSelection || yStartSelection != yEndSelection)) {
      for (int y = Math.max(0, yStart);
          y < Math.min(yStart + linesOnScreen + 1 + 2, vectorLines.size());
          y++) {
        String currentLine = vectorLines.elementAt(y).toString();
        int width = 0;

        for (int x = 0; x < currentLine.length(); x++) {
          int previousWidth = (x == 0) ? 0 : inputFont.charWidth(currentLine.charAt(x - 1));
          width += previousWidth;

          if (isSelected(x, y)) {
            g.setColor(0x000000);
            g.fillRect(
                width, y * inputHeight, inputFont.charWidth(currentLine.charAt(x)), inputHeight);

            g.setColor(0xffffff);
            g.drawChar(currentLine.charAt(x), width, y * inputHeight, Graphics.LEFT | Graphics.TOP);
          } else {
            g.setColor(0x000000);
            g.drawChar(currentLine.charAt(x), width, y * inputHeight, Graphics.LEFT | Graphics.TOP);
          }
        }

        if (currentLine.length() == 0) {
          if (isSelected(0, y)) {
            g.setColor(0x000000);
            g.fillRect(0, y * inputHeight, 5, inputHeight);
          }
        }
      }
    } else {
      for (int y = Math.max(0, yStart);
          y < Math.min(yStart + linesOnScreen + 1 + 2, vectorLines.size());
          y++) {
        g.drawString(
            vectorLines.elementAt(y).toString(), 0, y * inputHeight, Graphics.LEFT | Graphics.TOP);
      }
    }
  }
コード例 #30
0
ファイル: VCaretEntry.java プロジェクト: timburrow/OpenVnmrJ
 public void adjustFont(int w, int h) {
   if (h <= 0) return;
   int oldH = rHeight;
   if (font == null) {
     font = getFont();
     fontH = font.getSize();
     rHeight = fontH;
   }
   nHeight = h;
   if (fontH >= h) rHeight = h - 2;
   else rHeight = fontH;
   if ((rHeight < 10) && (fontH > 10)) rHeight = 10;
   if (oldH != rHeight) {
     // Font  curFont = font.deriveFont((float) rHeight);
     Font curFont = DisplayOptions.getFont(font.getName(), font.getStyle(), rHeight);
     setFont(curFont);
   }
   if (rHeight > h) rHeight = h;
 }