home *** CD-ROM | disk | FTP | other *** search
- package FontViewer.components;
-
- import FontViewer.windows.MainWindow;
- import java.awt.BorderLayout;
- import java.awt.GraphicsEnvironment;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseEvent;
- import java.awt.event.WindowEvent;
- import javax.swing.JList;
- import javax.swing.JPanel;
- import javax.swing.JScrollPane;
- import javax.swing.border.Border;
-
- public class SystemFontsPanel extends JPanel implements ListPanel {
- // $FF: renamed from: mw FontViewer.windows.MainWindow
- private MainWindow field_0;
- private String[] names;
- private String location;
- private JList systemFontsList;
- private JScrollPane systemFontsScrollPane;
-
- public SystemFontsPanel(MainWindow mw) {
- this.field_0 = mw;
- this.initComponents();
- this.initSystemFonts();
- }
-
- private void initSystemFonts() {
- this.names = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
- this.location = "System Font";
- this.systemFontsList.setListData(this.names);
- }
-
- public String[] getItem(int itemNumber) {
- String[] s = new String[3];
- if (itemNumber >= 0 && itemNumber < this.names.length) {
- s[0] = this.names[itemNumber];
- s[1] = this.location;
- s[2] = itemNumber + "";
- }
-
- return s;
- }
-
- public int getNumItems() {
- int items = 0;
- if (this.names != null) {
- items = this.names.length;
- }
-
- return items;
- }
-
- public String[] getCurrentItem() {
- String[] s = new String[3];
- int p = this.systemFontsList.getSelectedIndex();
- if (p >= 0) {
- s[0] = this.names[p];
- s[1] = this.location;
- s[2] = p + "";
- }
-
- return s;
- }
-
- public int getCurrentItemNum() {
- return this.systemFontsList.getSelectedIndex();
- }
-
- public void selectItem(String name, String loc) {
- this.systemFontsList.setSelectedValue(name, true);
- int p = this.systemFontsList.getSelectedIndex();
- if (p >= 0) {
- this.field_0.setCurrentFont(this.names[p], this.location, p);
- }
-
- }
-
- public void selectNext() {
- int i = this.systemFontsList.getSelectedIndex();
- if (i >= 0) {
- if (i + 1 < this.names.length) {
- ++i;
- }
-
- this.setCurrentItem(i, true);
- } else {
- this.setCurrentItem(0, true);
- }
-
- }
-
- public void selectPrev() {
- int i = this.systemFontsList.getSelectedIndex();
- if (i >= 0) {
- if (i - 1 >= 0) {
- --i;
- }
-
- this.setCurrentItem(i, true);
- } else {
- this.setCurrentItem(0, true);
- }
-
- }
-
- private void setCurrentItem(int p, boolean internal) {
- if (internal) {
- this.systemFontsList.setSelectedIndex(p);
- int spos = p * (this.systemFontsScrollPane.getVerticalScrollBar().getMaximum() / this.names.length);
- spos -= this.systemFontsScrollPane.getSize().height / 2;
- this.systemFontsScrollPane.getVerticalScrollBar().setValue(spos);
- }
-
- if (p >= 0) {
- this.field_0.setCurrentFont(this.names[p], this.location, p);
- }
-
- }
-
- private void initComponents() {
- this.systemFontsScrollPane = new JScrollPane();
- this.systemFontsList = new JList();
- this.setLayout(new BorderLayout());
- this.systemFontsScrollPane.setBorder((Border)null);
- this.systemFontsList.setSelectionMode(0);
- this.systemFontsList.addKeyListener(new 1(this));
- this.systemFontsList.addMouseListener(new 2(this));
- this.systemFontsScrollPane.setViewportView(this.systemFontsList);
- this.add(this.systemFontsScrollPane, "Center");
- }
-
- private void systemFontsListKeyReleased(KeyEvent evt) {
- this.setCurrentItem(this.systemFontsList.getSelectedIndex(), false);
- }
-
- private void systemFontsListMouseClicked(MouseEvent evt) {
- this.setCurrentItem(this.systemFontsList.getSelectedIndex(), false);
- }
-
- private void exitForm(WindowEvent evt) {
- }
-
- // $FF: synthetic method
- static void access$000(SystemFontsPanel x0, KeyEvent x1) {
- x0.systemFontsListKeyReleased(x1);
- }
-
- // $FF: synthetic method
- static void access$100(SystemFontsPanel x0, MouseEvent x1) {
- x0.systemFontsListMouseClicked(x1);
- }
- }
-