diff --git a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/HorizontalGridOptical.java b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/HorizontalGridOptical.java index 4bef26a516ef495e12db14917e5c036631dd3293..25b4698f7f3e34d007a56f8a4efcaa9584e8962f 100644 --- a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/HorizontalGridOptical.java +++ b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/HorizontalGridOptical.java @@ -48,6 +48,7 @@ public class HorizontalGridOptical extends HVOpticalBasePanel { super(artGetter); constraints.insets = new Insets(8,8,8,8); //3,3,3,3); + constraints.fill = GridBagConstraints.HORIZONTAL; } @Override diff --git a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/HorizontalMixedOptical.java b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/HorizontalMixedOptical.java index e7b02200be0231ea4de27f7fbaffad5beaaaa87f..0880e78d9622f79aa1531fb8765c597cf9cf49ff 100644 --- a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/HorizontalMixedOptical.java +++ b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/HorizontalMixedOptical.java @@ -25,10 +25,7 @@ package edu.nps.moves.qrtda.elements.gui; import java.awt.Component; import java.awt.Dimension; import java.lang.reflect.Method; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JComponent; -import javax.swing.JPanel; +import javax.swing.*; /** * 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 currentRowCol.setOpaque(false); currentRowCol.setLayout(new BoxLayout(currentRowCol, BoxLayout.LINE_AXIS)); currentRowCol.add(comp); - currentRowCol.add(Box.createRigidArea(new Dimension(10, 10))); currentRowCol.setAlignmentX(Component.LEFT_ALIGNMENT); currentRowCol.setAlignmentY(Component.TOP_ALIGNMENT); @@ -68,6 +64,7 @@ public class HorizontalMixedOptical extends HVOpticalMixedWidthBasePanel if (currentRowCol == null) addComponentNewRowOrColumn(comp); else { + currentRowCol.add(Box.createRigidArea(new Dimension(10, 10))); currentRowCol.add(comp); } } diff --git a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/VerticalGridOptical.java b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/VerticalGridOptical.java index b9bd285385b7aa7257c2de6ac4d8bf00dc85ec6d..7032611f0fdcdbcc01a395c27cfc7e76bb4403b7 100644 --- a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/VerticalGridOptical.java +++ b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/VerticalGridOptical.java @@ -25,8 +25,10 @@ package edu.nps.moves.qrtda.elements.gui; import java.awt.*; import java.lang.reflect.Method; +import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JComponent; +import javax.swing.JLabel; /** * VerticalGridOptical.java created on Apr 13, 2017 @@ -46,6 +48,7 @@ public class VerticalGridOptical extends HVOpticalBasePanel implements OpticalCo super(getArt); constraints.insets = new Insets(3,3,3,3); constraints.anchor = GridBagConstraints.NORTHWEST; + constraints.fill = GridBagConstraints.HORIZONTAL; // this fills, but image misaligned for small letters } @Override @@ -74,9 +77,9 @@ public class VerticalGridOptical extends HVOpticalBasePanel implements OpticalCo cons.gridy = 100; cons.gridx = 100; cons.weightx = 1.0; - cons.weighty = 1.0; - - add(Box.createRigidArea(new Dimension(5,5)),cons); + cons.weighty = 1.0; + JLabel lab = new JLabel(); lab.setSize(5, 5); + add(lab,cons); } @Override diff --git a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/VerticalMixedOptical.java b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/VerticalMixedOptical.java index 4a8c55128103ba33143bbb4885de8386bce8a518..a672296beed22e15a493f4b9e06252f40703321e 100644 --- a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/VerticalMixedOptical.java +++ b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/elements/gui/VerticalMixedOptical.java @@ -26,10 +26,7 @@ package edu.nps.moves.qrtda.elements.gui; import java.awt.Component; import java.awt.Dimension; import java.lang.reflect.Method; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JComponent; -import javax.swing.JPanel; +import javax.swing.*; /** * HorizontalMixedOptical.java created on Apr 17, 2017 @@ -58,8 +55,7 @@ public class VerticalMixedOptical extends HVOpticalMixedWidthBasePanel currentRowCol.setLayout(new BoxLayout(currentRowCol,BoxLayout.PAGE_AXIS)); comp.setAlignmentX(Component.LEFT_ALIGNMENT); currentRowCol.add(comp); - currentRowCol.add(Box.createRigidArea(new Dimension(10,10))); - + currentRowCol.setAlignmentX(Component.LEFT_ALIGNMENT); currentRowCol.setAlignmentY(Component.TOP_ALIGNMENT); add(currentRowCol); @@ -71,9 +67,9 @@ public class VerticalMixedOptical extends HVOpticalMixedWidthBasePanel if(currentRowCol == null) addComponentNewRowOrColumn(comp); else { + currentRowCol.add(Box.createRigidArea(new Dimension(10,10))); comp.setAlignmentX(Component.LEFT_ALIGNMENT); currentRowCol.add(comp); - currentRowCol.add(Box.createRigidArea(new Dimension(10,10))); } } diff --git a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/morseArt/MorseArtAndSound.java b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/morseArt/MorseArtAndSound.java index 869d9bdf30f6c56ebf1789fcb1fff7f5f7c633af..ba09f5a519a0bb94ed6295f94d82be72b6f021bd 100644 --- a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/morseArt/MorseArtAndSound.java +++ b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/morseArt/MorseArtAndSound.java @@ -131,10 +131,8 @@ public class MorseArtAndSound jc.setToolTipText(Character.toString(ch)); 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) @@ -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; public static JComponent[][] getAlphaString(String s, int size, Color background) @@ -160,7 +158,8 @@ public class MorseArtAndSound int letterSize = size * MORSE_LETTER_SIZE_FACTOR_NUMERATOR / MORSE_LETTER_SIZE_FACTOR_DENOM; 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(); jc.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.darkGray, 1), BorderFactory.createEmptyBorder(3, 3, 3, 3))); diff --git a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/semaphoreArt/LabeledComponent.java b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/semaphoreArt/LabeledComponent.java index 0a9f9465685f2afe8c8ea21206067fd5135b9fff..2bad6563f8457fd50b71495cd4a3d590ee5b653d 100644 --- a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/semaphoreArt/LabeledComponent.java +++ b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/semaphoreArt/LabeledComponent.java @@ -25,6 +25,7 @@ package edu.nps.moves.qrtda.semaphoreArt; import java.awt.*; import javax.swing.*; +import javax.swing.border.Border; /** * LabeledComponent.java created on Mar 1, 2017 @@ -48,21 +49,38 @@ public class LabeledComponent extends JPanel this(comp,size,s,background,SwingConstants.CENTER); } 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; super.setLayout(new GridBagLayout()); GridBagConstraints cons = new GridBagConstraints(); cons.gridx = GridBagConstraints.RELATIVE; cons.gridy = 0; - cons.insets = new Insets(0,0,0,0); - super.add(comp, cons); - label = new JLabel(s); + label = new JLabel("<html>"+s); label.setHorizontalAlignment(align); 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); - super.add(label,cons); //BorderLayout.SOUTH); + super.add(comp, cons); 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 diff --git a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/semaphoreArt/SemaphoreArt.java b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/semaphoreArt/SemaphoreArt.java index 83ca3daa2613005ee4e6f3cdb33def82fb5b151f..fddd4f6e9be5edcb1f948cb15266ee69d292a905 100644 --- a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/semaphoreArt/SemaphoreArt.java +++ b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/semaphoreArt/SemaphoreArt.java @@ -222,7 +222,6 @@ public class SemaphoreArt try { BufferedImage bi = SvgImageLoader.LoadSvgWithWidth(url, size); JLabel lab = new JLabel(new ImageIcon(bi)); - lab.setBorder(BorderFactory.createLineBorder(Color.lightGray, 1)); return lab; } catch(IOException ex) { @@ -237,7 +236,7 @@ public class SemaphoreArt int adjSize = size * SEMAPHORE_LETTER_SIZE_FACTOR_NUMERATOR / SEMAPHORE_LETTER_SIZE_FACTOR_DENOM; 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); } } diff --git a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/signalflagsArt/SignalFlagArt.java b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/signalflagsArt/SignalFlagArt.java index e89c977404137be995730eb53ff22adff45fb0df..ffd936ed0508e7c0adeddd9b86440eb0bad751c8 100644 --- a/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/signalflagsArt/SignalFlagArt.java +++ b/OpticalSignalingCommsToolbox/src/main/java/edu/nps/moves/qrtda/signalflagsArt/SignalFlagArt.java @@ -314,11 +314,14 @@ public class SignalFlagArt 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) { + 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); - 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