diff options
author | David Schweinsberg <[email protected]> | 2016-01-05 00:16:08 -0800 |
---|---|---|
committer | David Schweinsberg <[email protected]> | 2016-01-05 00:16:08 -0800 |
commit | 5f53490f6486872affe1c4a8e989da7a326f5fff (patch) | |
tree | 3c78a62bc5a065f1804a2f3b502bec7be4de85b5 /src | |
parent | 732313e8447c7d76986478d8fcd8ba716f8894c7 (diff) |
CharacterMap cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/net/java/dev/typecast/edit/CharacterMap.java | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/net/java/dev/typecast/edit/CharacterMap.java b/src/net/java/dev/typecast/edit/CharacterMap.java index 38fece3..9fc6d30 100644 --- a/src/net/java/dev/typecast/edit/CharacterMap.java +++ b/src/net/java/dev/typecast/edit/CharacterMap.java @@ -1,9 +1,7 @@ /* - * $Id: CharacterMap.java,v 1.4 2007-01-25 08:41:56 davidsch Exp $ - * * Typecast - The Font Development Environment * - * Copyright (c) 2004 David Schweinsberg + * Copyright (c) 2004-2016 David Schweinsberg * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +18,6 @@ package net.java.dev.typecast.edit; -import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; @@ -28,35 +25,24 @@ import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; -import java.awt.Rectangle; - import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; - import java.awt.geom.AffineTransform; - import java.util.ArrayList; - import javax.swing.AbstractListModel; -import javax.swing.ListCellRenderer; import javax.swing.JComponent; import javax.swing.JList; import javax.swing.JScrollPane; -import javax.swing.ScrollPaneConstants; - +import javax.swing.ListCellRenderer; import net.java.dev.typecast.app.framework.EditorView; - import net.java.dev.typecast.ot.OTFont; - import net.java.dev.typecast.ot.table.CmapFormat; - import net.java.dev.typecast.render.GlyphImageFactory; /** * An editor for the character-to-glyph map, as represented in the CmapTable. * @author <a href="mailto:[email protected]">David Schweinsberg</a> - * @version $Id: CharacterMap.java,v 1.4 2007-01-25 08:41:56 davidsch Exp $ */ public class CharacterMap extends JScrollPane implements EditorView { @@ -69,12 +55,12 @@ public class CharacterMap extends JScrollPane implements EditorView { private CmapFormat _cmapFormat; private OTFont _font; private AffineTransform _tx; - private Font _labelFont = new Font("SansSerif", Font.PLAIN, 10); + private final Font _labelFont = new Font("SansSerif", Font.PLAIN, 10); private class Mapping { - private int _charCode; - private int _glyphCode; + private final int _charCode; + private final int _glyphCode; public Mapping(int charCode, int glyphCode) { _charCode = charCode; @@ -108,12 +94,13 @@ public class CharacterMap extends JScrollPane implements EditorView { private Mapping _mapping; private int _index; private boolean _isSelected; - private AffineTransform _imageTx = + private final AffineTransform _imageTx = new AffineTransform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0); /** * Renders each individual cell */ + @Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; @@ -138,6 +125,7 @@ public class CharacterMap extends JScrollPane implements EditorView { CELL_HEIGHT - 1); } + @Override public Component getListCellRendererComponent( JList list, Object value, @@ -160,6 +148,7 @@ public class CharacterMap extends JScrollPane implements EditorView { setName("Character Map"); } + @Override public void setModel(OTFont font, Object obj) { if (obj instanceof CmapFormat) { _font = font; @@ -169,7 +158,7 @@ public class CharacterMap extends JScrollPane implements EditorView { _listModel = new AbstractListModel() { private static final long serialVersionUID = 1L; - private ArrayList<Mapping> _mappings = new ArrayList<Mapping>(); + private final ArrayList<Mapping> _mappings = new ArrayList<>(); { for (int i = 0; i < _cmapFormat.getRangeCount(); ++i) { @@ -180,10 +169,12 @@ public class CharacterMap extends JScrollPane implements EditorView { } } + @Override public Object getElementAt(int index) { return _mappings.get(index); } + @Override public int getSize() { return _mappings.size(); } @@ -200,6 +191,7 @@ public class CharacterMap extends JScrollPane implements EditorView { // Create a mouse listener so we can listen to double-clicks MouseListener mouseListener = new MouseAdapter() { + @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int index = list.locationToIndex(e.getPoint()); |