All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.l2fprod.common.swing.DefaultFontChooserModel Maven / Gradle / Ivy

Go to download

Orbit, a versatile image analysis software for biological image-based quantification

There is a newer version: 3.15
Show newest version
/**
 * $ $ License.
 *
 * Copyright $ L2FProd.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.l2fprod.common.swing;

import java.awt.GraphicsEnvironment;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Iterator;
import java.util.ResourceBundle;
import java.util.SortedMap;

import com.l2fprod.common.swing.plaf.FontChooserUI;

/**
 * Default implementation of the FontChooserModel. It returns all
 * available fonts and commonly used font sizes.
 */
public class DefaultFontChooserModel implements FontChooserModel {

  private static final int[] DEFAULT_FONT_SIZES = {6, 8, 10, 11, 12, 14, 16,
      18, 20, 22, 24, 26, 28, 32, 40, 48, 56, 64, 72};

  private final String[] fontFamilies;
  private final String[] charSets;
  private final String previewMessage;
  
  public DefaultFontChooserModel() {
    fontFamilies = GraphicsEnvironment.getLocalGraphicsEnvironment()
        .getAvailableFontFamilyNames();
    Arrays.sort(fontFamilies);

    SortedMap map = Charset.availableCharsets();
    charSets = new String[map.size()];
    int i = 0;
    for (Iterator iter = map.keySet().iterator(); iter.hasNext(); i++) {
      charSets[i] = (String)iter.next();
    }
    
    ResourceBundle bundle =
      ResourceBundle.getBundle(FontChooserUI.class.getName() + "RB");
    previewMessage = bundle.getString("FontChooserUI.previewText");
  }

  public String[] getFontFamilies(String charSetName) {
    return fontFamilies;
  }

  public int[] getDefaultSizes() {
    return DEFAULT_FONT_SIZES;
  }

  public String[] getCharSets() {
    return charSets;
  }

  public String getPreviewMessage(String charSetName) {
    return previewMessage;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy