Exemplo n.º 1
0
  /**
   * If the font is set to null, then the day font will default to 9/11th's of the L&F's Button
   * default font.
   *
   * <p>Otherwise, the day font is set as given.
   *
   * @param font The font to set.
   */
  public void setDayFont(Font font) {
    if (font == null && dayFont != null || !font.equals(dayFont)) {

      dayFont = font;
      if (isDisplayable()) setupDayFonts();
    }
  }
Exemplo n.º 2
0
  /**
   * If the font is set to null, then the font used to display today's date as text will default to
   * the L&amp;F's Label default font.
   *
   * <p>Otherwise, the font used to display today's date is set as given.
   *
   * @param font The font to set.
   */
  public void setTodayFont(Font font) {
    if (font == null && todayFont != null || !font.equals(todayFont)) {

      todayFont = font;
      if (isDisplayable()) setupTodayFont();
    }
  }
 /**
  * Set the default contour label font. <br>
  * <B>Property Change:</B> <code>labelFont</code>.
  */
 public void setLabelFont(Font font) {
   if (labelFont_ == null || !labelFont_.equals(font)) {
     Font tempOld = labelFont_;
     labelFont_ = font;
     changes_.firePropertyChange("labelFont", tempOld, labelFont_);
   }
 }
Exemplo n.º 4
0
  /**
   * If the font is set to null, then the title font (for the Month Year title) will default to the
   * L&amp;F's Label default font.
   *
   * <p>Otherwise, the title font is set as given.
   *
   * @param font The font to set.
   */
  public void setTitleFont(Font font) {
    if (font == null && titleFont != null || !font.equals(titleFont)) {

      titleFont = font;
      if (isDisplayable()) setupTitleFont();
    }
  }
Exemplo n.º 5
0
  public static void exportFix(
      final Debrief.Wrappers.FixWrapper fix,
      final org.w3c.dom.Element parent,
      final org.w3c.dom.Document doc) {
    /*
    <!ELEMENT fix (colour?, centre)>
    <!ATTLIST fix
      course CDATA #REQUIRED
      speed CDATA #REQUIRED
      dtg CDATA #REQUIRED
      visible (TRUE|FALSE) "TRUE"
      label CDATA #IMPLIED
      LabelShowing (TRUE|FALSE) #IMPLIED
      SymbolShowing (TRUE|FALSE) "TRUE"
      LabelLocation (Top|Left|Bottom|Centre|Right) "Left"
        */
    final Element eFix = doc.createElement("fix");
    eFix.setAttribute(
        "Course", "" + writeThis(MWC.Algorithms.Conversions.Rads2Degs(fix.getCourse())));
    eFix.setAttribute("Speed", "" + writeThis(fix.getSpeed()));
    eFix.setAttribute("Dtg", writeThis(fix.getTime()));
    eFix.setAttribute("Visible", writeThis(fix.getVisible()));
    eFix.setAttribute("Label", toXML(fix.getLabel()));
    eFix.setAttribute("LabelShowing", writeThis(fix.getLabelShowing()));
    eFix.setAttribute("LineShowing", writeThis(fix.getLineShowing()));
    eFix.setAttribute("SymbolShowing", writeThis(fix.getSymbolShowing()));
    eFix.setAttribute("ArrowShowing", writeThis(fix.getArrowShowing()));
    lp.setValue(fix.getLabelLocation());
    eFix.setAttribute("LabelLocation", lp.getAsText());

    // note, we are accessing the "actual" colour for this fix, we are not using the
    // normal getColor method which may return the track colour
    final java.awt.Color fCol = fix.getActualColor();
    if (fCol != null) {
      // just see if the colour is different to the parent
      final java.awt.Color parentColor = fix.getTrackWrapper().getColor();
      if (fCol.equals(parentColor)) {
        // hey, don't bother outputting the parent color
      } else {
        MWC.Utilities.ReaderWriter.XML.Util.ColourHandler.exportColour(fCol, eFix, doc);
      }
    }

    // and the font
    final java.awt.Font theFont = fix.getFont();
    if (theFont != null) {
      // ok, compare the font to the parent
      if (theFont.equals(fix.getTrackWrapper().getTrackFont())) {
        // don't bother outputting the font - it's the same as the parent anyway
      } else {
        FontHandler.exportFont(theFont, eFix, doc);
      }
    }

    // and now the centre item,
    MWC.Utilities.ReaderWriter.XML.Util.LocationHandler.exportLocation(
        fix.getLocation(), "centre", eFix, doc);

    parent.appendChild(eFix);
  }
 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());
 }
Exemplo n.º 7
0
  @Nullable
  Font getFontAbleToDisplay(LookupElementPresentation p) {
    String sampleString = p.getItemText() + p.getTailText() + p.getTypeText();

    // assume a single font can display all lookup item chars
    Set<Font> fonts = ContainerUtil.newHashSet();
    for (int i = 0; i < sampleString.length(); i++) {
      fonts.add(
          EditorUtil.fontForChar(sampleString.charAt(i), Font.PLAIN, myLookup.getEditor())
              .getFont());
    }

    eachFont:
    for (Font font : fonts) {
      if (font.equals(myNormalFont)) continue;

      for (int i = 0; i < sampleString.length(); i++) {
        if (!font.canDisplay(sampleString.charAt(i))) {
          continue eachFont;
        }
      }
      return font;
    }
    return null;
  }
Exemplo n.º 8
0
  /**
   * Paints the specified line onto the graphics context. Note that this method munges the offset
   * and count values of the segment.
   *
   * @param line The line segment
   * @param tokens The token list for the line
   * @param styles The syntax style list
   * @param expander The tab expander used to determine tab stops. May be null
   * @param gfx The graphics context
   * @param x The x co-ordinate
   * @param y The y co-ordinate
   * @return The x co-ordinate, plus the width of the painted string
   */
  public static int paintSyntaxLine(
      Segment line,
      Token tokens,
      SyntaxStyle[] styles,
      TabExpander expander,
      Graphics gfx,
      int x,
      int y) {
    Font defaultFont = gfx.getFont();
    Color defaultColor = gfx.getColor();

    int offset = 0;
    for (; ; ) {
      byte id = tokens.id;
      if (id == Token.END) break;

      int length = tokens.length;
      if (id == Token.NULL) {
        if (!defaultColor.equals(gfx.getColor())) gfx.setColor(defaultColor);
        if (!defaultFont.equals(gfx.getFont())) gfx.setFont(defaultFont);
      } else styles[id].setGraphicsFlags(gfx, defaultFont);

      line.count = length;
      x = Utilities.drawTabbedText(line, x, y, gfx, expander, 0);
      line.offset += length;
      offset += length;

      tokens = tokens.next;
    }

    return x;
  }
Exemplo n.º 9
0
 @SuppressWarnings("deprecation")
 void sync(GlyphView v) {
   Font f = v.getFont();
   if ((metrics == null) || (!f.equals(metrics.getFont()))) {
     // fetch a new FontMetrics
     Container c = v.getContainer();
     metrics = (c != null) ? c.getFontMetrics(f) : Toolkit.getDefaultToolkit().getFontMetrics(f);
   }
 }
Exemplo n.º 10
0
  public void setFont(Font font) {
    if (font.equals(currentFont)) return;

    if (textRenderers.containsKey(font)) {
      textRenderer = textRenderers.get(font);
      return;
    }

    // if (textRenderer != null)
    //	textRenderer.dispose();

    this.textRenderer = new TextRenderer(font);
    textRenderers.put(font, textRenderer);
  }
Exemplo n.º 11
0
  /** Returns the specified font, but with the style's bold, underline and italic flags applied. */
  public Font getStyledFont(Font font) {
    if (font == null) throw new NullPointerException("font param must not" + " be null");
    if (font.equals(lastFont)) return lastStyledFont;
    lastFont = font;

    lastStyledFont =
        new Font(
            font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize());
    if (underlined) {
      Map<TextAttribute, Object> attr = new Hashtable<TextAttribute, Object>();
      attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
      lastStyledFont = lastStyledFont.deriveFont(attr);
    }
    return lastStyledFont;
  }
Exemplo n.º 12
0
 /**
  * Synchronize this painter with the current state of the view.
  *
  * @param v Sync to this view.
  */
 @SuppressWarnings("deprecation")
 void sync(GlyphView v) {
   Font f = v.getFont();
   if ((metrics == null) || (!f.equals(metrics.getFont()))) {
     // fetch a new FontMetrics
     Toolkit kit;
     Component c = v.getContainer();
     if (c != null) {
       kit = c.getToolkit();
     } else {
       kit = Toolkit.getDefaultToolkit();
     }
     metrics = kit.getFontMetrics(f);
   }
 }
Exemplo n.º 13
0
 /** Returns the font metrics for the styled font. */
 public FontMetrics getFontMetrics(Font font, JComponent comp) {
   if (font == null) throw new NullPointerException("font param must not" + " be null");
   if (font.equals(lastFont) && fontMetrics != null) return fontMetrics;
   lastFont = font;
   lastStyledFont =
       new Font(
           font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize());
   if (underlined) {
     Map<TextAttribute, Object> attr = new Hashtable<TextAttribute, Object>();
     attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
     lastStyledFont = lastStyledFont.deriveFont(attr);
   }
   // fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(lastStyledFont);
   fontMetrics = comp.getFontMetrics(lastStyledFont);
   return fontMetrics;
 }