/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* JPanelAll.java
*
* Created on 27.04.2009, 22:13:10
*/
package xplanetconfigurator.gui;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.text.JTextComponent;
import xplanetconfigurator.util.XPlanetRessourceFinder;
/**
*
* @author tom
*/
public class JPanelControlConfigFileLabellingMarkers extends ControlPanel implements IAskForUserTextLine {
private Logger logger;
/** Creates new form JPanelAll */
public JPanelControlConfigFileLabellingMarkers(MainFrame mainFrame) {
super(mainFrame);
initComponents();
this.logger = Logger.getLogger(this.getClass().getName());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jPanelControls = new javax.swing.JPanel();
jTextFieldParameterTextColor = new javax.swing.JTextField();
jLabelTextColor = new javax.swing.JLabel();
jLabelMarkerFont = new javax.swing.JLabel();
jTextFieldParameterMarkerFont = new javax.swing.JTextField();
jTextFieldParameterMarkerColor = new javax.swing.JTextField();
jLabelMarkerFontSize = new javax.swing.JLabel();
jTextFieldParameterMarkerFontSize = new javax.swing.JTextField();
jTextFieldParameterMaxRadiusForLabel = new javax.swing.JTextField();
jLabelMinRadiusForLabel = new javax.swing.JLabel();
jTextFieldParameterMinRadiusForLabel = new javax.swing.JTextField();
jLabelMirRadiusForMarkers = new javax.swing.JLabel();
jTextFieldParameterMinRadiusForMarkers = new javax.swing.JTextField();
jLabelMarkerColor = new javax.swing.JLabel();
jLabelMaxRadiusForLabel = new javax.swing.JLabel();
jPanelMarkerFile = new javax.swing.JPanel();
jLabelOrbitMarkerFile = new javax.swing.JLabel();
jComboBoxMarkerFile = new javax.swing.JComboBox();
jButtonAdd = new javax.swing.JButton();
jButtonDelete = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
jPanelHelp = new javax.swing.JPanel();
jLabelHelp = new javax.swing.JLabel();
jScrollPane = new javax.swing.JScrollPane();
jTextAreaHelp = new javax.swing.JTextArea();
addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent evt) {
formComponentShown(evt);
}
});
setLayout(new java.awt.GridBagLayout());
jPanelControls.setName("jPanelControls"); // NOI18N
jPanelControls.setLayout(new java.awt.GridBagLayout());
jTextFieldParameterTextColor.setMinimumSize(new java.awt.Dimension(70, 20));
jTextFieldParameterTextColor.setName("jTextFieldParameterTextColor"); // NOI18N
jTextFieldParameterTextColor.setPreferredSize(new java.awt.Dimension(70, 20));
jTextFieldParameterTextColor.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
jTextFieldParameterTextColorCaretUpdate(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jTextFieldParameterTextColor, gridBagConstraints);
jLabelTextColor.setText("<html><b>text_color"); // NOI18N
jLabelTextColor.setName("jLabelTextColor"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jLabelTextColor, gridBagConstraints);
jLabelMarkerFont.setText("<html><b>marker_font"); // NOI18N
jLabelMarkerFont.setName("jLabelMarkerFont"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jLabelMarkerFont, gridBagConstraints);
jTextFieldParameterMarkerFont.setMinimumSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMarkerFont.setName("jTextFieldParameterMarkerFont"); // NOI18N
jTextFieldParameterMarkerFont.setPreferredSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMarkerFont.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
jTextFieldParameterMarkerFontCaretUpdate(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jTextFieldParameterMarkerFont, gridBagConstraints);
jTextFieldParameterMarkerColor.setMinimumSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMarkerColor.setName("jTextFieldParameterMarkerColor"); // NOI18N
jTextFieldParameterMarkerColor.setPreferredSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMarkerColor.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
jTextFieldParameterMarkerColorCaretUpdate(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jTextFieldParameterMarkerColor, gridBagConstraints);
jLabelMarkerFontSize.setText("<html><b>marker_fontsize"); // NOI18N
jLabelMarkerFontSize.setName("jLabelMarkerFontSize"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jLabelMarkerFontSize, gridBagConstraints);
jTextFieldParameterMarkerFontSize.setMinimumSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMarkerFontSize.setName("jTextFieldParameterMarkerFontSize"); // NOI18N
jTextFieldParameterMarkerFontSize.setPreferredSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMarkerFontSize.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
jTextFieldParameterMarkerFontSizeCaretUpdate(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jTextFieldParameterMarkerFontSize, gridBagConstraints);
jTextFieldParameterMaxRadiusForLabel.setMinimumSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMaxRadiusForLabel.setName("jTextFieldParameterMaxRadiusForLabel"); // NOI18N
jTextFieldParameterMaxRadiusForLabel.setPreferredSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMaxRadiusForLabel.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
jTextFieldParameterMaxRadiusForLabelCaretUpdate(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 5;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jTextFieldParameterMaxRadiusForLabel, gridBagConstraints);
jLabelMinRadiusForLabel.setText("<html><b>min_radius_for_label"); // NOI18N
jLabelMinRadiusForLabel.setName("jLabelMinRadiusForLabel"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 5;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jLabelMinRadiusForLabel, gridBagConstraints);
jTextFieldParameterMinRadiusForLabel.setMinimumSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMinRadiusForLabel.setName("jTextFieldParameterMinRadiusForLabel"); // NOI18N
jTextFieldParameterMinRadiusForLabel.setPreferredSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMinRadiusForLabel.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
jTextFieldParameterMinRadiusForLabelCaretUpdate(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 5;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jTextFieldParameterMinRadiusForLabel, gridBagConstraints);
jLabelMirRadiusForMarkers.setText("<html><b>min_radius_for_markers"); // NOI18N
jLabelMirRadiusForMarkers.setName("jLabelMirRadiusForMarkers"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jLabelMirRadiusForMarkers, gridBagConstraints);
jTextFieldParameterMinRadiusForMarkers.setMinimumSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMinRadiusForMarkers.setName("jTextFieldParameterMinRadiusForMarkers"); // NOI18N
jTextFieldParameterMinRadiusForMarkers.setPreferredSize(new java.awt.Dimension(70, 20));
jTextFieldParameterMinRadiusForMarkers.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
jTextFieldParameterMinRadiusForMarkersCaretUpdate(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jTextFieldParameterMinRadiusForMarkers, gridBagConstraints);
jLabelMarkerColor.setText("<html><b>marker_color"); // NOI18N
jLabelMarkerColor.setName("jLabelMarkerColor"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jLabelMarkerColor, gridBagConstraints);
jLabelMaxRadiusForLabel.setText("<html><b>max_radius_for_label"); // NOI18N
jLabelMaxRadiusForLabel.setName("jLabelMaxRadiusForLabel"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 5;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jLabelMaxRadiusForLabel, gridBagConstraints);
jPanelMarkerFile.setName("jPanelMarkerFile"); // NOI18N
jPanelMarkerFile.setLayout(new java.awt.GridBagLayout());
jLabelOrbitMarkerFile.setText("<html><b>marker_file"); // NOI18N
jLabelOrbitMarkerFile.setName("jLabelOrbitMarkerFile"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelMarkerFile.add(jLabelOrbitMarkerFile, gridBagConstraints);
jComboBoxMarkerFile.setMinimumSize(new java.awt.Dimension(100, 18));
jComboBoxMarkerFile.setName("jComboBoxMarkerFile"); // NOI18N
jComboBoxMarkerFile.setPreferredSize(new java.awt.Dimension(100, 18));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelMarkerFile.add(jComboBoxMarkerFile, gridBagConstraints);
jButtonAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/xplanetconfigurator/gui/resources/img/Button-Add-16x16.gif"))); // NOI18N
jButtonAdd.setName("jButtonAdd"); // NOI18N
jButtonAdd.setPreferredSize(new java.awt.Dimension(25, 25));
jButtonAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAddActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 3;
gridBagConstraints.gridy = 1;
jPanelMarkerFile.add(jButtonAdd, gridBagConstraints);
jButtonDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/xplanetconfigurator/gui/resources/img/Button-Delete-16x16.gif"))); // NOI18N
jButtonDelete.setName("jButtonDelete"); // NOI18N
jButtonDelete.setPreferredSize(new java.awt.Dimension(25, 25));
jButtonDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonDeleteActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 4;
gridBagConstraints.gridy = 1;
jPanelMarkerFile.add(jButtonDelete, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelControls.add(jPanelMarkerFile, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
add(jPanelControls, gridBagConstraints);
jSeparator1.setName("jSeparator1"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
add(jSeparator1, gridBagConstraints);
jPanelHelp.setName("jPanelHelp"); // NOI18N
jPanelHelp.setLayout(new java.awt.GridBagLayout());
jLabelHelp.setText("Help Text of XPlanet");
jLabelHelp.setName("jLabelHelp"); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
jPanelHelp.add(jLabelHelp, gridBagConstraints);
jScrollPane.setName("jScrollPane"); // NOI18N
jTextAreaHelp.setColumns(20);
jTextAreaHelp.setEditable(false);
jTextAreaHelp.setRows(5);
jTextAreaHelp.setText("text_color\nSpecify the color for the markers and body label. The default is red.\n\nmarker_color\nSpecify the default color for all markers. This color will be\noverridden if a color is specified for a marker in the marker file.\nThe default is red.\n\nmarker_file\nSpecify a file containing user defined marker data to display on the\nmap. This option may be used more than once. The default is no\nmarker file. See the README and sample files in the xplanet/markers\ndirectory for more information.\n\nmarker_font\nSpecify the default font for all markers for this body. This option\nmay be overridden inside the marker file. The default is to use the\nvalue from the command line -font option.\n\nmarker_fontsize\nSpecify the default font size for all markers for this body. This\noption may be overridden inside the marker file. The default is to\nuse the value from the command line -fontsize option.\n\nmax_radius_for_label\nDon't draw a label for the body if its radius is greater than this\nvalue. The default is 3 pixels.\n\nmin_radius_for_label\nDon't draw a label for the body if its radius is less than this\nvalue. The default is 0.01 pixel.\n\nmin_radius_for_markers\nDon't draw markers on the body if its radius is less than this value.\nThe default is 40 pixels.\n\n"); // NOI18N
jTextAreaHelp.setName("jTextAreaHelp"); // NOI18N
jScrollPane.setViewportView(jTextAreaHelp);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
jPanelHelp.add(jScrollPane, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
add(jPanelHelp, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
this.receiveCommandLineParameters();
}//GEN-LAST:event_formComponentShown
private void jTextFieldParameterTextColorCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldParameterTextColorCaretUpdate
this.sendConfigParameter(this.jTextFieldParameterTextColor, "text_color", "(?i)(\\btext_color\\b=)(\\S*)");
}//GEN-LAST:event_jTextFieldParameterTextColorCaretUpdate
private void jTextFieldParameterMarkerFontCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldParameterMarkerFontCaretUpdate
this.sendConfigParameter(this.jTextFieldParameterMarkerFont, "marker_font", "(?i)(\\bmarker_font\\b=)(\\S*)");
}//GEN-LAST:event_jTextFieldParameterMarkerFontCaretUpdate
private void jTextFieldParameterMarkerColorCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldParameterMarkerColorCaretUpdate
this.sendConfigParameter(this.jTextFieldParameterMarkerColor, "marker_color", "(?i)(\\bmarker_color\\b=)(\\S*)");
}//GEN-LAST:event_jTextFieldParameterMarkerColorCaretUpdate
private void jTextFieldParameterMarkerFontSizeCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldParameterMarkerFontSizeCaretUpdate
this.sendConfigParameter(this.jTextFieldParameterMarkerFontSize, "marker_fontsize", "(?i)(\\bmarker_fontsize\\b=)(\\S*)");
}//GEN-LAST:event_jTextFieldParameterMarkerFontSizeCaretUpdate
private void jTextFieldParameterMaxRadiusForLabelCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldParameterMaxRadiusForLabelCaretUpdate
this.sendConfigParameter(this.jTextFieldParameterMaxRadiusForLabel, "max_radius_for_label", "(?i)(\\bmax_radius_for_label\\b=)(\\S*)");
}//GEN-LAST:event_jTextFieldParameterMaxRadiusForLabelCaretUpdate
private void jTextFieldParameterMinRadiusForLabelCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldParameterMinRadiusForLabelCaretUpdate
this.sendConfigParameter(this.jTextFieldParameterMinRadiusForLabel, "min_radius_for_label", "(?i)(\\bmin_radius_for_label\\b=)(\\S*)");
}//GEN-LAST:event_jTextFieldParameterMinRadiusForLabelCaretUpdate
private void jTextFieldParameterMinRadiusForMarkersCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextFieldParameterMinRadiusForMarkersCaretUpdate
this.sendConfigParameter(this.jTextFieldParameterMinRadiusForMarkers, "min_radius_for_markers", "(?i)(\\bmin_radius_for_markers\\b=)(\\S*)");
}//GEN-LAST:event_jTextFieldParameterMinRadiusForMarkersCaretUpdate
private void jButtonAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddActionPerformed
// JDialogTextLineInput dialog = new JDialogTextLineInput("Please give a URL", this);
// dialog.setVisible(true);
this.chooseMarkerFromDirectory();
}//GEN-LAST:event_jButtonAddActionPerformed
private void jButtonDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteActionPerformed
String url = (String) this.jComboBoxMarkerFile.getSelectedItem();
this.jComboBoxMarkerFile.removeItem(url);
this.sendConfigParameter(this.jComboBoxMarkerFile, "marker_file", "(?i)(\\bmarker_file\\b=)(.*)");
}//GEN-LAST:event_jButtonDeleteActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonAdd;
private javax.swing.JButton jButtonDelete;
private javax.swing.JComboBox jComboBoxMarkerFile;
private javax.swing.JLabel jLabelHelp;
private javax.swing.JLabel jLabelMarkerColor;
private javax.swing.JLabel jLabelMarkerFont;
private javax.swing.JLabel jLabelMarkerFontSize;
private javax.swing.JLabel jLabelMaxRadiusForLabel;
private javax.swing.JLabel jLabelMinRadiusForLabel;
private javax.swing.JLabel jLabelMirRadiusForMarkers;
private javax.swing.JLabel jLabelOrbitMarkerFile;
private javax.swing.JLabel jLabelTextColor;
private javax.swing.JPanel jPanelControls;
private javax.swing.JPanel jPanelHelp;
private javax.swing.JPanel jPanelMarkerFile;
private javax.swing.JScrollPane jScrollPane;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JTextArea jTextAreaHelp;
private javax.swing.JTextField jTextFieldParameterMarkerColor;
private javax.swing.JTextField jTextFieldParameterMarkerFont;
private javax.swing.JTextField jTextFieldParameterMarkerFontSize;
private javax.swing.JTextField jTextFieldParameterMaxRadiusForLabel;
private javax.swing.JTextField jTextFieldParameterMinRadiusForLabel;
private javax.swing.JTextField jTextFieldParameterMinRadiusForMarkers;
private javax.swing.JTextField jTextFieldParameterTextColor;
// End of variables declaration//GEN-END:variables
/**
* React to caret updates of the text area to add/remove/modify
* the marker file names in the combo box. This is done
* by caret updates of the text area. The caret updates are (text of text area)
* is send to this line and handled with by the receiveCommandLineParameters(String).
* There is another way to add/remove marker file names in the combo box: via
* the buttons and the dialog.
* @param parameters
* @return
*/
@Override
boolean receiveCommandLineParameters(String parameters) throws XPlanetException {
boolean hasFound = this.findParameterString(parameters);
if (hasFound) {
String sectionText = this.getWholeSection();
String regExpr = "(?i)(marker_color=)(\\S+)";
this.receiveParameter(sectionText, regExpr, this.jTextFieldParameterMarkerColor, 2);
regExpr = "(?i)(marker_font=)(\\S+)";
this.receiveParameter(sectionText, regExpr, this.jTextFieldParameterMarkerFont, 2);
regExpr = "(?i)(marker_fontsize=)(\\S+)";
this.receiveParameter(sectionText, regExpr, this.jTextFieldParameterMarkerFontSize, 2);
regExpr = "(?i)(max_radius_for_label=)(\\S+)";
this.receiveParameter(sectionText, regExpr, this.jTextFieldParameterMaxRadiusForLabel, 2);
regExpr = "(?i)(min_radius_for_label=)(\\S+)";
this.receiveParameter(sectionText, regExpr, this.jTextFieldParameterMinRadiusForLabel, 2);
regExpr = "(?i)(min_radius_for_markers=)(\\S+)";
this.receiveParameter(sectionText, regExpr, this.jTextFieldParameterMinRadiusForMarkers, 2);
regExpr = "(?i)(text_color=)(\\S+)";
this.receiveParameter(sectionText, regExpr, this.jTextFieldParameterTextColor, 2);
String regExprListItems = "(?i)(marker_file=)(.*)";
this.receiveParameter(parameters, null, regExprListItems, 2, this.jComboBoxMarkerFile);
return true;
} else {
this.jComboBoxMarkerFile.removeAllItems();
this.logger.finest("Did not find own parameter");
return false;
}
}
public String getText() {
return this.jTextAreaHelp.getText();
}
public JTextComponent getTextComponent() {
return this.jTextAreaHelp;
}
/**
* React to the dialog. The user can press a button and open a dialog
* to add a new marker file name. There is another way to add/remove/modify
* the marker file names in the combo box: over the text area. This is done
* by caret updates of the text area. The caret updates are (text of text area)
* is send to this line and handled with by the receiveCommandLineParameters(String).
* @param markerFileName
*/
public void receiveUserTextLine(String textLine) {
this.jComboBoxMarkerFile.addItem(textLine);
this.sendConfigParameter(this.jComboBoxMarkerFile, "marker_file", "(?i)(\\bmarker_file\\b=)(.*)");
}
/**
* Open a file chooser and show the content of the marker directory to
* add a marker file.
*/
private void chooseMarkerFromDirectory() {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
XPlanetRessourceFinder rf = new XPlanetRessourceFinder();
String downloaderRootDir = rf.getRootDirectoryForDownloads();
String dir = downloaderRootDir + File.separator + "markers";
// Select the directory
File f = new File(dir);
String selectedFileName = (String) this.jComboBoxMarkerFile.getSelectedItem();
if (selectedFileName != null) {
// Select the selected marker file
String s = dir + File.separator + selectedFileName;
f = new File(s);
}
fc.setSelectedFile(f);
fc.setMultiSelectionEnabled(false);
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = fc.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
this.logger.finer("User choose a marker file from the markers directory: " + file.getAbsolutePath());
String fileName = file.getName();
if (fileName != null) {
this.logger.finer("The file name is: " + fileName + ". Adding to list...");
}
// Do not allow double entries
int count = this.jComboBoxMarkerFile.getItemCount();
for (int i = 0; i < count; i++) {
String s = (String) this.jComboBoxMarkerFile.getItemAt(i);
if (s.equalsIgnoreCase(fileName)) {
this.logger.finer("The file name is already in the list: " + fileName);
return;
}
}
this.jComboBoxMarkerFile.addItem(fileName);
this.sendConfigParameter(this.jComboBoxMarkerFile, "marker_file", "(?i)(\\bmarker_file\\b=)(.*)");
}
}
@Override
void receiveCommandLineParameters() {
String params = this.getMainFrame().getConfigParameters();
try {
this.receiveCommandLineParameters(params);
} catch (XPlanetException ex) {
this.logger.log(Level.SEVERE, null, ex);
}
}
}