Skip to content
Snippets Groups Projects
Commit f91a8463 authored by J. M. Bailey's avatar J. M. Bailey
Browse files

Tweeks to letter displays

parent e01000df
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 27 deletions
...@@ -48,6 +48,7 @@ public class HorizontalGridOptical extends HVOpticalBasePanel ...@@ -48,6 +48,7 @@ public class HorizontalGridOptical extends HVOpticalBasePanel
{ {
super(artGetter); super(artGetter);
constraints.insets = new Insets(8,8,8,8); //3,3,3,3); constraints.insets = new Insets(8,8,8,8); //3,3,3,3);
constraints.fill = GridBagConstraints.HORIZONTAL;
} }
@Override @Override
......
...@@ -25,10 +25,7 @@ package edu.nps.moves.qrtda.elements.gui; ...@@ -25,10 +25,7 @@ package edu.nps.moves.qrtda.elements.gui;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import javax.swing.Box; import javax.swing.*;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
/** /**
* HorizontalMixedOptical.java created on Apr 17, 2017 MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu * HorizontalMixedOptical.java created on Apr 17, 2017 MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu
...@@ -55,7 +52,6 @@ public class HorizontalMixedOptical extends HVOpticalMixedWidthBasePanel ...@@ -55,7 +52,6 @@ public class HorizontalMixedOptical extends HVOpticalMixedWidthBasePanel
currentRowCol.setOpaque(false); currentRowCol.setOpaque(false);
currentRowCol.setLayout(new BoxLayout(currentRowCol, BoxLayout.LINE_AXIS)); currentRowCol.setLayout(new BoxLayout(currentRowCol, BoxLayout.LINE_AXIS));
currentRowCol.add(comp); currentRowCol.add(comp);
currentRowCol.add(Box.createRigidArea(new Dimension(10, 10)));
currentRowCol.setAlignmentX(Component.LEFT_ALIGNMENT); currentRowCol.setAlignmentX(Component.LEFT_ALIGNMENT);
currentRowCol.setAlignmentY(Component.TOP_ALIGNMENT); currentRowCol.setAlignmentY(Component.TOP_ALIGNMENT);
...@@ -68,6 +64,7 @@ public class HorizontalMixedOptical extends HVOpticalMixedWidthBasePanel ...@@ -68,6 +64,7 @@ public class HorizontalMixedOptical extends HVOpticalMixedWidthBasePanel
if (currentRowCol == null) if (currentRowCol == null)
addComponentNewRowOrColumn(comp); addComponentNewRowOrColumn(comp);
else { else {
currentRowCol.add(Box.createRigidArea(new Dimension(10, 10)));
currentRowCol.add(comp); currentRowCol.add(comp);
} }
} }
......
...@@ -25,8 +25,10 @@ package edu.nps.moves.qrtda.elements.gui; ...@@ -25,8 +25,10 @@ package edu.nps.moves.qrtda.elements.gui;
import java.awt.*; import java.awt.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import javax.swing.BorderFactory;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel;
/** /**
* VerticalGridOptical.java created on Apr 13, 2017 * VerticalGridOptical.java created on Apr 13, 2017
...@@ -46,6 +48,7 @@ public class VerticalGridOptical extends HVOpticalBasePanel implements OpticalCo ...@@ -46,6 +48,7 @@ public class VerticalGridOptical extends HVOpticalBasePanel implements OpticalCo
super(getArt); super(getArt);
constraints.insets = new Insets(3,3,3,3); constraints.insets = new Insets(3,3,3,3);
constraints.anchor = GridBagConstraints.NORTHWEST; constraints.anchor = GridBagConstraints.NORTHWEST;
constraints.fill = GridBagConstraints.HORIZONTAL; // this fills, but image misaligned for small letters
} }
@Override @Override
...@@ -74,9 +77,9 @@ public class VerticalGridOptical extends HVOpticalBasePanel implements OpticalCo ...@@ -74,9 +77,9 @@ public class VerticalGridOptical extends HVOpticalBasePanel implements OpticalCo
cons.gridy = 100; cons.gridy = 100;
cons.gridx = 100; cons.gridx = 100;
cons.weightx = 1.0; cons.weightx = 1.0;
cons.weighty = 1.0; cons.weighty = 1.0;
JLabel lab = new JLabel(); lab.setSize(5, 5);
add(Box.createRigidArea(new Dimension(5,5)),cons); add(lab,cons);
} }
@Override @Override
......
...@@ -26,10 +26,7 @@ package edu.nps.moves.qrtda.elements.gui; ...@@ -26,10 +26,7 @@ package edu.nps.moves.qrtda.elements.gui;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import javax.swing.Box; import javax.swing.*;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
/** /**
* HorizontalMixedOptical.java created on Apr 17, 2017 * HorizontalMixedOptical.java created on Apr 17, 2017
...@@ -58,8 +55,7 @@ public class VerticalMixedOptical extends HVOpticalMixedWidthBasePanel ...@@ -58,8 +55,7 @@ public class VerticalMixedOptical extends HVOpticalMixedWidthBasePanel
currentRowCol.setLayout(new BoxLayout(currentRowCol,BoxLayout.PAGE_AXIS)); currentRowCol.setLayout(new BoxLayout(currentRowCol,BoxLayout.PAGE_AXIS));
comp.setAlignmentX(Component.LEFT_ALIGNMENT); comp.setAlignmentX(Component.LEFT_ALIGNMENT);
currentRowCol.add(comp); currentRowCol.add(comp);
currentRowCol.add(Box.createRigidArea(new Dimension(10,10)));
currentRowCol.setAlignmentX(Component.LEFT_ALIGNMENT); currentRowCol.setAlignmentX(Component.LEFT_ALIGNMENT);
currentRowCol.setAlignmentY(Component.TOP_ALIGNMENT); currentRowCol.setAlignmentY(Component.TOP_ALIGNMENT);
add(currentRowCol); add(currentRowCol);
...@@ -71,9 +67,9 @@ public class VerticalMixedOptical extends HVOpticalMixedWidthBasePanel ...@@ -71,9 +67,9 @@ public class VerticalMixedOptical extends HVOpticalMixedWidthBasePanel
if(currentRowCol == null) if(currentRowCol == null)
addComponentNewRowOrColumn(comp); addComponentNewRowOrColumn(comp);
else { else {
currentRowCol.add(Box.createRigidArea(new Dimension(10,10)));
comp.setAlignmentX(Component.LEFT_ALIGNMENT); comp.setAlignmentX(Component.LEFT_ALIGNMENT);
currentRowCol.add(comp); currentRowCol.add(comp);
currentRowCol.add(Box.createRigidArea(new Dimension(10,10)));
} }
} }
......
...@@ -131,10 +131,8 @@ public class MorseArtAndSound ...@@ -131,10 +131,8 @@ public class MorseArtAndSound
jc.setToolTipText(Character.toString(ch)); jc.setToolTipText(Character.toString(ch));
arLis.add(jc); arLis.add(jc);
} }
JComponent comp = getSwingComponent(SPACESVGFILE,size);
arLis.add(comp);
return arLis;//labelWrap(arLis.toArray(new JComponent[arLis.size()]),Character.toString(ch)); return arLis;
} }
private static boolean[] getLetterDitDahs(char c) private static boolean[] getLetterDitDahs(char c)
...@@ -143,7 +141,7 @@ public class MorseArtAndSound ...@@ -143,7 +141,7 @@ public class MorseArtAndSound
} }
private static final int MORSE_LETTER_SIZE_FACTOR_NUMERATOR = 3; private static final int MORSE_LETTER_SIZE_FACTOR_NUMERATOR = 2;//3;
private static final int MORSE_LETTER_SIZE_FACTOR_DENOM = 10; private static final int MORSE_LETTER_SIZE_FACTOR_DENOM = 10;
public static JComponent[][] getAlphaString(String s, int size, Color background) public static JComponent[][] getAlphaString(String s, int size, Color background)
...@@ -160,7 +158,8 @@ public class MorseArtAndSound ...@@ -160,7 +158,8 @@ public class MorseArtAndSound
int letterSize = size * MORSE_LETTER_SIZE_FACTOR_NUMERATOR / MORSE_LETTER_SIZE_FACTOR_DENOM; int letterSize = size * MORSE_LETTER_SIZE_FACTOR_NUMERATOR / MORSE_LETTER_SIZE_FACTOR_DENOM;
letterSize = (int)((float)letterSize * HIRES_TABLE_TEXT_FACTOR); letterSize = (int)((float)letterSize * HIRES_TABLE_TEXT_FACTOR);
jc = new LabeledComponent(jc,letterSize,new String(new char[]{c}),background); //,SwingConstants.LEFT); String str = new String(new char[]{c,'&','n','b','s','p',';'});
jc = new LabeledComponent(jc,letterSize,str,background);
Dimension pdc = jc.getPreferredSize(); Dimension pdc = jc.getPreferredSize();
jc.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.darkGray, 1), jc.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.darkGray, 1),
BorderFactory.createEmptyBorder(3, 3, 3, 3))); BorderFactory.createEmptyBorder(3, 3, 3, 3)));
......
...@@ -25,6 +25,7 @@ package edu.nps.moves.qrtda.semaphoreArt; ...@@ -25,6 +25,7 @@ package edu.nps.moves.qrtda.semaphoreArt;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
/** /**
* LabeledComponent.java created on Mar 1, 2017 * LabeledComponent.java created on Mar 1, 2017
...@@ -48,21 +49,38 @@ public class LabeledComponent extends JPanel ...@@ -48,21 +49,38 @@ public class LabeledComponent extends JPanel
this(comp,size,s,background,SwingConstants.CENTER); this(comp,size,s,background,SwingConstants.CENTER);
} }
public LabeledComponent(JComponent comp, Integer size, String s , Color background, int align) public LabeledComponent(JComponent comp, Integer size, String s , Color background, int align)
{
this (comp,size,s,background,align,false);
}
public LabeledComponent(JComponent comp, Integer size, String s, Color background, int align, boolean pad)
{ {
this.comp = comp; this.comp = comp;
super.setLayout(new GridBagLayout()); super.setLayout(new GridBagLayout());
GridBagConstraints cons = new GridBagConstraints(); GridBagConstraints cons = new GridBagConstraints();
cons.gridx = GridBagConstraints.RELATIVE; cons.gridx = GridBagConstraints.RELATIVE;
cons.gridy = 0; cons.gridy = 0;
cons.insets = new Insets(0,0,0,0); label = new JLabel("<html>"+s);
super.add(comp, cons);
label = new JLabel(s);
label.setHorizontalAlignment(align); label.setHorizontalAlignment(align);
sizeAndColor2Font(label,size,background); sizeAndColor2Font(label,size,background);
cons.insets = new Insets(0,0,0,0);
super.add(label,cons);
cons.weightx = 1.0;
label = new JLabel(); // spacer
label.setOpaque(false);
super.add(label,cons);
cons.weightx = 0.0;
cons.insets = new Insets(0,5,0,0); cons.insets = new Insets(0,5,0,0);
super.add(label,cons); //BorderLayout.SOUTH); super.add(comp, cons);
super.setOpaque(false); super.setOpaque(false);
if(pad)
super.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.gray, 1),
BorderFactory.createEmptyBorder(3, 3, 3, 3)));
else
super.setBorder(BorderFactory.createLineBorder(Color.darkGray, 1));
} }
@Override @Override
......
...@@ -222,7 +222,6 @@ public class SemaphoreArt ...@@ -222,7 +222,6 @@ public class SemaphoreArt
try { try {
BufferedImage bi = SvgImageLoader.LoadSvgWithWidth(url, size); BufferedImage bi = SvgImageLoader.LoadSvgWithWidth(url, size);
JLabel lab = new JLabel(new ImageIcon(bi)); JLabel lab = new JLabel(new ImageIcon(bi));
lab.setBorder(BorderFactory.createLineBorder(Color.lightGray, 1));
return lab; return lab;
} }
catch(IOException ex) { catch(IOException ex) {
...@@ -237,7 +236,7 @@ public class SemaphoreArt ...@@ -237,7 +236,7 @@ public class SemaphoreArt
int adjSize = size * SEMAPHORE_LETTER_SIZE_FACTOR_NUMERATOR / SEMAPHORE_LETTER_SIZE_FACTOR_DENOM; int adjSize = size * SEMAPHORE_LETTER_SIZE_FACTOR_NUMERATOR / SEMAPHORE_LETTER_SIZE_FACTOR_DENOM;
adjSize = (int)((float)adjSize * HIRES_TABLE_TEXT_FACTOR); adjSize = (int)((float)adjSize * HIRES_TABLE_TEXT_FACTOR);
return new LabeledComponent(comp,adjSize,s.toUpperCase(), background); return new LabeledComponent(comp,adjSize,s.toUpperCase(),background,SwingConstants.CENTER,true);
} }
} }
......
...@@ -314,11 +314,14 @@ public class SignalFlagArt ...@@ -314,11 +314,14 @@ public class SignalFlagArt
return new JLabel(new ImageIcon(new BufferedImage(size,size,BufferedImage.TYPE_INT_ARGB))); return new JLabel(new ImageIcon(new BufferedImage(size,size,BufferedImage.TYPE_INT_ARGB)));
} }
} }
private static final int SIGFLAG_LETTER_SIZE_FACTOR_NUMERATOR = 6;
private static final int SIGFLAG_LETER_SIZE_FACTOR_DENOMINATOR = 10;
private static JComponent labelWrap(JComponent comp, String s, int size, Color background) private static JComponent labelWrap(JComponent comp, String s, int size, Color background)
{ {
size = size * SIGFLAG_LETTER_SIZE_FACTOR_NUMERATOR / SIGFLAG_LETER_SIZE_FACTOR_DENOMINATOR;
size = (int)((float)size * HIRES_TABLE_TEXT_FACTOR * HIRES_TABLE_TEXT_FACTOR_FLAGS_EXTRA); size = (int)((float)size * HIRES_TABLE_TEXT_FACTOR * HIRES_TABLE_TEXT_FACTOR_FLAGS_EXTRA);
return new LabeledComponent(comp,size,s.toUpperCase(),background); return new LabeledComponent(comp,size,s.toUpperCase(),background,SwingConstants.CENTER,true);
} }
public static FlagImageIcon[] getIcons(String s, int size) throws IOException public static FlagImageIcon[] getIcons(String s, int size) throws IOException
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment