+
+ /**
+ * Restrict the given coordinate to a limited number of decimal places for display
+ * @param inCoord coordinate string
+ * @return chopped string
+ */
+ private static String restrictDP(String inCoord)
+ {
+ final int DECIMAL_PLACES = 7;
+ if (inCoord == null) return "";
+ final int dotPos = Math.max(inCoord.lastIndexOf('.'), inCoord.lastIndexOf(','));
+ if (dotPos >= 0) {
+ final int chopPos = dotPos + DECIMAL_PLACES;
+ if (chopPos < (inCoord.length()-1)) {
+ return inCoord.substring(0, chopPos);
+ }
+ }
+ return inCoord;
+ }
+
+ /**
+ * Make a details subpanel
+ * @param inNameKey key to use for top label
+ * @param inFont font for top label
+ * @return panel with correct layout, label
+ */
+ private static JPanel makeDetailsPanel(String inNameKey, Font inFont)
+ {
+ JPanel detailsPanel = new JPanel();
+ detailsPanel.setLayout(new BoxLayout(detailsPanel, BoxLayout.Y_AXIS));
+ detailsPanel.setBorder(BorderFactory.createCompoundBorder(
+ BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), BorderFactory.createEmptyBorder(3, 3, 3, 3))
+ );
+ JLabel detailsLabel = new JLabel(I18nManager.getText(inNameKey));
+ detailsLabel.setFont(inFont);
+ detailsPanel.add(detailsLabel);
+ return detailsPanel;
+ }
+
+ /**
+ * Create a little button for rotating the current photo
+ * @param inIcon icon to use (from IconManager)
+ * @param inFunction function to call (from FunctionLibrary)
+ * @return button object
+ */
+ private static JButton makeRotateButton(String inIcon, GenericFunction inFunction)
+ {
+ JButton button = new JButton(IconManager.getImageIcon(inIcon));
+ button.setToolTipText(I18nManager.getText(inFunction.getNameKey()));
+ button.setMargin(new Insets(0, 2, 0, 2));
+ button.addActionListener(new FunctionLauncher(inFunction));
+ return button;
+ }
+
+ /**
+ * @param inFullPath full file path or URL to be shortened
+ * @return shortened string from beginning of path
+ */
+ private static String shortenPath(String inFullPath)
+ {
+ // Chop off the home path if possible
+ final String homePath = System.getProperty("user.home").toLowerCase();
+ if (inFullPath != null && inFullPath.toLowerCase().startsWith(homePath)) {
+ inFullPath = inFullPath.substring(homePath.length()+1);
+ }
+ if (inFullPath == null || inFullPath.length() < 21) {
+ return inFullPath;
+ }
+ // path is too long
+ return inFullPath.substring(0, 20) + "...";
+ }