List of usage examples for java.text NumberFormat getInstance
public static final NumberFormat getInstance()
From source file:io.plaidapp.ui.DesignerNewsStory.java
private void bindDescription() { final TextView storyComment = (TextView) header.findViewById(R.id.story_comment); if (!TextUtils.isEmpty(story.comment)) { HtmlUtils.parseMarkdownAndSetText(storyComment, story.comment, markdown, new Bypass.LoadImageCallback() { @Override//from w ww .j a va 2 s . com public void loadImage(String src, ImageLoadingSpan loadingSpan) { Glide.with(DesignerNewsStory.this).load(src).asBitmap() .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new ImageSpanTarget(storyComment, loadingSpan)); } }); } else { storyComment.setVisibility(View.GONE); } upvoteStory = (TextView) header.findViewById(R.id.story_vote_action); upvoteStory.setText(getResources().getQuantityString(R.plurals.upvotes, story.vote_count, NumberFormat.getInstance().format(story.vote_count))); upvoteStory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { upvoteStory(); } }); final TextView share = (TextView) header.findViewById(R.id.story_share_action); share.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((AnimatedVectorDrawable) share.getCompoundDrawables()[1]).start(); startActivity(ShareCompat.IntentBuilder.from(DesignerNewsStory.this).setText(story.url) .setType("text/plain").setSubject(story.title).getIntent()); } }); TextView storyPosterTime = (TextView) header.findViewById(R.id.story_poster_time); SpannableString poster = new SpannableString(story.user_display_name.toLowerCase()); poster.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_CommentAuthor), 0, poster.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); CharSequence job = !TextUtils.isEmpty(story.user_job) ? "\n" + story.user_job.toLowerCase() : ""; CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(story.created_at.getTime(), System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS).toString().toLowerCase(); storyPosterTime.setText(TextUtils.concat(poster, job, "\n", timeAgo)); ImageView avatar = (ImageView) header.findViewById(R.id.story_poster_avatar); if (!TextUtils.isEmpty(story.user_portrait_url)) { Glide.with(this).load(story.user_portrait_url).placeholder(R.drawable.avatar_placeholder) .transform(circleTransform).into(avatar); } else { avatar.setVisibility(View.GONE); } }
From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java
private void addDataset(String pId, XYDataset pDataset) { if (chart == null) { setupChart(pId, pDataset);/* w w w.ja va 2s .c o m*/ } else { XYPlot plot = (XYPlot) chart.getPlot(); plot.setDataset(plot.getDatasetCount(), pDataset); NumberAxis axis = new NumberAxis(pId); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(0); nf.setMaximumFractionDigits(0); axis.setNumberFormatOverride(nf); plot.setRangeAxis(plot.getDatasetCount() - 1, axis); plot.setRangeAxisLocation(plot.getDatasetCount() - 1, AxisLocation.TOP_OR_LEFT); plot.mapDatasetToRangeAxis(plot.getDatasetCount() - 1, plot.getDatasetCount() - 1); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, jShowLines.isSelected()); renderer.setSeriesShapesVisible(0, jShowDataPoints.isSelected()); plot.setRenderer(plot.getDatasetCount() - 1, renderer); renderer.setDefaultItemLabelsVisible(jShowItemValues.isSelected()); renderer.setDefaultItemLabelGenerator(new org.jfree.chart.labels.StandardXYItemLabelGenerator()); renderer.setDefaultToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"), NumberFormat.getInstance())); axis.setAxisLinePaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint()); axis.setLabelPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint()); axis.setTickLabelPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint()); axis.setTickMarkPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint()); } }
From source file:hudson.plugins.plot.PlotData.java
/** * Generates the plot and stores it in the plot instance variable. * /*from w w w. j a va2s . c om*/ * @param forceGenerate if true, force the plot to be re-generated * even if the on-disk data hasn't changed */ private void generatePlot(boolean forceGenerate) { class Label implements Comparable<Label> { final private Integer buildNum; final private String buildDate; final private String text; public Label(String buildNum, String buildTime, String text) { this.buildNum = Integer.parseInt(buildNum); synchronized (DATE_FORMAT) { this.buildDate = DATE_FORMAT.format(new Date(Long.parseLong(buildTime))); } this.text = text; } public int compareTo(Label that) { return this.buildNum - that.buildNum; } @Override public boolean equals(Object o) { return o instanceof Label && ((Label) o).buildNum.equals(buildNum); } @Override public int hashCode() { return buildNum.hashCode(); } public String numDateString() { return "#" + buildNum + " (" + buildDate + ")"; } @Override public String toString() { return text != null ? text : numDateString(); } } LOGGER.fine("Generating plot from file: " + csvFilePath.getName()); PlotCategoryDataset dataset = new PlotCategoryDataset(); for (String[] record : rawPlotData) { // record: series y-value, series label, build number, build date, url int buildNum; try { buildNum = Integer.valueOf(record[2]); if (project.getBuildByNumber(buildNum) == null || buildNum > getRightBuildNum()) { continue; // skip this record } } catch (NumberFormatException nfe) { continue; // skip this record all together } Number value = null; try { value = Integer.valueOf(record[0]); } catch (NumberFormatException nfe) { try { value = Double.valueOf(record[0]); } catch (NumberFormatException nfe2) { continue; // skip this record all together } } String series = record[1]; Label xlabel = getUrlUseDescr() ? new Label(record[2], record[3], descriptionForBuild(buildNum)) : new Label(record[2], record[3], getBuildName(buildNum)); String url = null; if (record.length >= 5) url = record[4]; dataset.setValue(value, url, series, xlabel); } int numBuilds; try { numBuilds = Integer.parseInt(getURLNumBuilds()); } catch (NumberFormatException nfe) { numBuilds = DEFAULT_NUMBUILDS; } dataset.clipDataset(numBuilds); plot = createChart(dataset); CategoryPlot categoryPlot = (CategoryPlot) plot.getPlot(); categoryPlot.setDomainGridlinePaint(Color.black); categoryPlot.setRangeGridlinePaint(Color.black); categoryPlot.setDrawingSupplier(PlotData.supplier); CategoryAxis domainAxis = new ShiftedCategoryAxis(Messages.Plot_Build()); categoryPlot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.03); domainAxis.setCategoryMargin(0.0); for (Object category : dataset.getColumnKeys()) { Label label = (Label) category; if (label.text != null) { domainAxis.addCategoryLabelToolTip(label, label.numDateString()); } else { domainAxis.addCategoryLabelToolTip(label, descriptionForBuild(label.buildNum)); } } AbstractCategoryItemRenderer renderer = (AbstractCategoryItemRenderer) categoryPlot.getRenderer(); int numColors = dataset.getRowCount(); for (int i = 0; i < numColors; i++) { renderer.setSeriesPaint(i, new Color(Color.HSBtoRGB((1f / numColors) * i, 1f, 1f))); } renderer.setStroke(new BasicStroke(2.0f)); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator(Messages.Plot_Build() + " {1}: {2}", NumberFormat.getInstance())); renderer.setItemURLGenerator(new PointURLGenerator()); if (renderer instanceof LineAndShapeRenderer) { LineAndShapeRenderer lasRenderer = (LineAndShapeRenderer) renderer; lasRenderer.setShapesVisible(true); // TODO: deprecated, may be unnecessary } }
From source file:com.alvermont.terraj.planet.ui.MainFrame.java
/** This method is called from within the constructor to * initialize the form.//from ww w . j a v a 2 s . c om * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { jButton1 = new javax.swing.JButton(); jTabbedPane1 = new javax.swing.JTabbedPane(); projPanel = new javax.swing.JPanel(); projComboBox = new javax.swing.JComboBox<Projector>(); jLabel1 = new javax.swing.JLabel(); latSpinner = new javax.swing.JSpinner(); lonSpinner = new javax.swing.JSpinner(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); previewLabel = new javax.swing.JLabel(); heightfieldCheckbox = new javax.swing.JCheckBox(); jLabel17 = new javax.swing.JLabel(); NumberFormat format = NumberFormat.getInstance(); format.setMinimumFractionDigits(12); format.setMaximumFractionDigits(12); seedField = new JFormattedTextField(format); randomSeedButton = new javax.swing.JButton(); randomAllButton = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); vgridSpinner = new javax.swing.JSpinner(); hgridSpinner = new javax.swing.JSpinner(); outputJPanel = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); widthComboBox = new javax.swing.JComboBox<String>(); heightComboBox = new javax.swing.JComboBox<String>(); reverseCheckbox = new javax.swing.JCheckBox(); jLabel18 = new javax.swing.JLabel(); scaleSpinner = new javax.swing.JSpinner(); jPanel3 = new javax.swing.JPanel(); oceanColourButton = new javax.swing.JButton(); shoreColourButton = new javax.swing.JButton(); lowColourButton = new javax.swing.JButton(); highColourButton = new javax.swing.JButton(); mountainColourButton = new javax.swing.JButton(); rockyColourButton = new javax.swing.JButton(); peakColourButton = new javax.swing.JButton(); spaceColourButton = new javax.swing.JButton(); lineColourButton = new javax.swing.JButton(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jLabel15 = new javax.swing.JLabel(); jLabel16 = new javax.swing.JLabel(); randomAllColourButton = new javax.swing.JButton(); randomOceanColourButton = new javax.swing.JButton(); randomShoreColourButton = new javax.swing.JButton(); randomLowColourButton = new javax.swing.JButton(); randomHighColourButton = new javax.swing.JButton(); randomMountainColourButton = new javax.swing.JButton(); randomRockyColourButton = new javax.swing.JButton(); randomPeakColourButton = new javax.swing.JButton(); randomSpaceColourButton = new javax.swing.JButton(); randomLineColourButton = new javax.swing.JButton(); optionsPanel = new javax.swing.JPanel(); altColourCheckbox = new javax.swing.JCheckBox(); laticCheckbox = new javax.swing.JCheckBox(); shadeCheckbox = new javax.swing.JCheckBox(); shadeAngleSpinner = new javax.swing.JSpinner(); lighterSpinner = new javax.swing.JSpinner(); jLabel19 = new javax.swing.JLabel(); outlineCheckbox = new javax.swing.JCheckBox(); edgesCheckbox = new javax.swing.JCheckBox(); jMenuBar1 = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); loadParamsItem = new javax.swing.JMenuItem(); saveParamsItem = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JSeparator(); exitItem = new javax.swing.JMenuItem(); optionsMenu = new javax.swing.JMenu(); nativeLAFCheckbox = new javax.swing.JCheckBoxMenuItem(); helpMenu = new javax.swing.JMenu(); aboutItem = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Terrain Generator"); jButton1.setAction(new GenerateAction(this, "Generate")); jButton1.setText("Generate ..."); jButton1.setToolTipText("Generate the terrain using the parameters you have set up"); jButton1.setPreferredSize(new java.awt.Dimension(120, 23)); jTabbedPane1.setToolTipText(""); projPanel.setRequestFocusEnabled(false); projComboBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { projComboBoxActionPerformed(evt); } }); jLabel1.setText("Projection Type"); jLabel1.setToolTipText("Specify the map projection to be used"); latSpinner.setModel(new SpinnerNumberModel(0.0, -90.0, 90.0, 0.001)); latSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { latSpinnerStateChanged(evt); } }); lonSpinner.setModel(new SpinnerNumberModel(0.0, -180.0, 180.0, 0.001)); lonSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { lonSpinnerStateChanged(evt); } }); jLabel2.setText("Latitude"); jLabel2.setToolTipText("Set the latitude for the projection"); jLabel3.setText("Longitude"); jLabel3.setToolTipText("Set the longitude for the projection"); previewLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); previewLabel.setText("Not Initialized!"); previewLabel.setToolTipText("A preview of the map projection"); previewLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); heightfieldCheckbox.setText("Don't use a projection, generate heightfield output"); heightfieldCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); heightfieldCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0)); heightfieldCheckbox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { heightfieldCheckboxActionPerformed(evt); } }); jLabel17.setText("Seed value for random terrain generation"); jLabel17.setToolTipText("Set the seed value. A particular seed will produce the same terrain"); seedField.setHorizontalAlignment(javax.swing.JTextField.RIGHT); seedField.setText("0.0"); seedField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { seedFieldActionPerformed(evt); } }); randomSeedButton.setText("Random Seed"); randomSeedButton.setToolTipText("Pick a random seed value"); randomSeedButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomSeedButtonActionPerformed(evt); } }); randomAllButton.setText("Randomize All"); randomAllButton.setToolTipText("Randomize all the items on this page"); randomAllButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomAllButtonActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout projPanelLayout = new org.jdesktop.layout.GroupLayout(projPanel); projPanel.setLayout(projPanelLayout); projPanelLayout.setHorizontalGroup(projPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, projPanelLayout.createSequentialGroup() .addContainerGap() .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(org.jdesktop.layout.GroupLayout.LEADING, previewLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 662, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, heightfieldCheckbox) .add(projPanelLayout.createSequentialGroup() .add(projPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel1).add(jLabel2).add(jLabel3).add(jLabel17)) .add(145, 145, 145) .add(projPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, lonSpinner, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, latSpinner, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, projComboBox, 0, 318, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, seedField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, projPanelLayout .createSequentialGroup().add(randomSeedButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 116, Short.MAX_VALUE) .add(randomAllButton))))) .addContainerGap())); projPanelLayout.setVerticalGroup(projPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(projPanelLayout.createSequentialGroup().addContainerGap() .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1).add(projComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(latSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel2)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lonSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel3)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel17).add(seedField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(randomAllButton).add(randomSeedButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(previewLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(heightfieldCheckbox) .addContainerGap())); jTabbedPane1.addTab("Project", null, projPanel, "Set the projection parameters"); jLabel4.setText("Add a grid at this vertical spacing in degrees (0 = none)"); jLabel5.setText("Add a grid at this horizontal spacing in degrees (0 = none)"); vgridSpinner.setModel(new SpinnerNumberModel(0.0, -90.0, 90.0, 0.001)); vgridSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { vgridSpinnerStateChanged(evt); } }); hgridSpinner.setModel(new SpinnerNumberModel(0.0, -180.0, 180.0, 0.001)); hgridSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { hgridSpinnerStateChanged(evt); } }); org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup().addContainerGap() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel4) .add(jLabel5)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 290, Short.MAX_VALUE) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(hgridSpinner).add(vgridSpinner, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE)) .addContainerGap())); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup().addContainerGap() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel4).add(vgridSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel5).add(hgridSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addContainerGap(334, Short.MAX_VALUE))); jTabbedPane1.addTab("Grid", null, jPanel1, "Set the grid parameters"); jLabel6.setText("Output width in pixels"); jLabel7.setText("Output height in pixels"); widthComboBox.setEditable(true); widthComboBox.setModel(new javax.swing.DefaultComboBoxModel<>( new String[] { "320", "640", "800", "1024", "1280", "1600" })); widthComboBox.setSelectedIndex(2); widthComboBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { widthComboBoxActionPerformed(evt); } }); heightComboBox.setEditable(true); heightComboBox.setModel( new javax.swing.DefaultComboBoxModel<>(new String[] { "200", "480", "600", "1024", "1200" })); heightComboBox.setSelectedIndex(2); heightComboBox.addActionListener(evt -> heightComboBoxActionPerformed(evt)); /*new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { heightComboBoxActionPerformed(evt); } });*/ reverseCheckbox.setText("Reverse the background on the output"); reverseCheckbox.setToolTipText("If selected will invert the background colour"); reverseCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); reverseCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0)); jLabel18.setText("Scale (1.0 = normal)"); scaleSpinner.setModel(new SpinnerNumberModel(1.0, 0.01, 10.0, 0.01)); scaleSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { scaleSpinnerStateChanged(evt); } }); org.jdesktop.layout.GroupLayout outputJPanelLayout = new org.jdesktop.layout.GroupLayout(outputJPanel); outputJPanel.setLayout(outputJPanelLayout); outputJPanelLayout.setHorizontalGroup(outputJPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(outputJPanelLayout.createSequentialGroup().addContainerGap().add(outputJPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(outputJPanelLayout.createSequentialGroup() .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel6).add(jLabel7)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 458, Short.MAX_VALUE) .add(outputJPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) .add(heightComboBox, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(widthComboBox, 0, 85, Short.MAX_VALUE))) .add(outputJPanelLayout.createSequentialGroup().add(jLabel18) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 401, Short.MAX_VALUE) .add(scaleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(reverseCheckbox)).addContainerGap())); outputJPanelLayout.setVerticalGroup(outputJPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(outputJPanelLayout.createSequentialGroup().addContainerGap() .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel6).add(widthComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel7).add(heightComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel18).add(scaleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(reverseCheckbox) .addContainerGap(283, Short.MAX_VALUE))); jTabbedPane1.addTab("Output", null, outputJPanel, "Set the output parameters"); oceanColourButton.setText("Select ..."); oceanColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { oceanColourButtonActionPerformed(evt); } }); shoreColourButton.setText("Select ..."); shoreColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { shoreColourButtonActionPerformed(evt); } }); lowColourButton.setText("Select ..."); lowColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lowColourButtonActionPerformed(evt); } }); highColourButton.setText("Select ..."); highColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { highColourButtonActionPerformed(evt); } }); mountainColourButton.setText("Select ..."); mountainColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mountainColourButtonActionPerformed(evt); } }); rockyColourButton.setText("Select ..."); rockyColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rockyColourButtonActionPerformed(evt); } }); peakColourButton.setText("Select ..."); peakColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { peakColourButtonActionPerformed(evt); } }); spaceColourButton.setText("Select ..."); spaceColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { spaceColourButtonActionPerformed(evt); } }); lineColourButton.setText("Select ..."); lineColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lineColourButtonActionPerformed(evt); } }); jLabel8.setText("Colour to use for ocean depths"); jLabel9.setText("Colour to use for shores"); jLabel10.setText("Colour to use for lowlands"); jLabel11.setText("Colour to use for highlands"); jLabel12.setText("Colour to use for mountains"); jLabel13.setText("Colour to use for high rocky peaks"); jLabel14.setText("Colour to use for peaks"); jLabel15.setText("Colour to use for space"); jLabel16.setText("Colour to use for lines"); randomAllColourButton.setText("Randomize All Colours"); randomAllColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomAllColourButtonActionPerformed(evt); } }); randomOceanColourButton.setText("Random"); randomOceanColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomOceanColourButtonActionPerformed(evt); } }); randomShoreColourButton.setText("Random"); randomShoreColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomShoreColourButtonActionPerformed(evt); } }); randomLowColourButton.setText("Random"); randomLowColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomLowColourButtonActionPerformed(evt); } }); randomHighColourButton.setText("Random"); randomHighColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomHighColourButtonActionPerformed(evt); } }); randomMountainColourButton.setText("Random"); randomMountainColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomMountainColourButtonActionPerformed(evt); } }); randomRockyColourButton.setText("Random"); randomRockyColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomRockyColourButtonActionPerformed(evt); } }); randomPeakColourButton.setText("Random"); randomPeakColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomPeakColourButtonActionPerformed(evt); } }); randomSpaceColourButton.setText("Random"); randomSpaceColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomSpaceColourButtonActionPerformed(evt); } }); randomLineColourButton.setText("Random"); randomLineColourButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { randomLineColourButtonActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup().addContainerGap().add(jPanel3Layout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add( jPanel3Layout .createSequentialGroup().add( jPanel3Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING) .add(jLabel8).add(jLabel9).add(jLabel10) .add(jLabel11).add(jLabel12).add(jLabel13) .add(jLabel14).add(jLabel15).add(jLabel16)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 222, Short.MAX_VALUE) .add(jPanel3Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.TRAILING) .add(randomOceanColourButton).add(randomShoreColourButton) .add(randomLowColourButton).add(randomMountainColourButton) .add(randomRockyColourButton).add( randomPeakColourButton) .add(randomSpaceColourButton).add(randomLineColourButton) .add(randomHighColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING, false) .add(org.jdesktop.layout.GroupLayout.TRAILING, oceanColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, shoreColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, lowColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, highColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, mountainColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, rockyColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, peakColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, spaceColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, lineColourButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .add(org.jdesktop.layout.GroupLayout.TRAILING, randomAllColourButton)) .addContainerGap())); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup().addContainerGap() .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(oceanColourButton).add(jLabel8).add(randomOceanColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(shoreColourButton).add(jLabel9).add(randomShoreColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lowColourButton).add(jLabel10).add(randomLowColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(highColourButton).add(jLabel11).add(randomHighColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(mountainColourButton).add(jLabel12).add(randomMountainColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(rockyColourButton).add(jLabel13).add(randomRockyColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(peakColourButton).add(jLabel14).add(randomPeakColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(spaceColourButton).add(jLabel15).add(randomSpaceColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lineColourButton).add(jLabel16).add(randomLineColourButton)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 91, Short.MAX_VALUE) .add(randomAllColourButton).addContainerGap())); jTabbedPane1.addTab("Colours", null, jPanel3, "Set the colour parameters"); altColourCheckbox.setText("Use an alternative colouring scheme"); altColourCheckbox.setToolTipText("An alternate colour scheme more like an atlas"); altColourCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); altColourCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0)); altColourCheckbox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { altColourCheckboxActionPerformed(evt); } }); laticCheckbox.setText("Use latitude based colouring"); laticCheckbox.setToolTipText("Colour terrain based on latitude"); laticCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); laticCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0)); laticCheckbox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { laticCheckboxActionPerformed(evt); } }); shadeCheckbox.setText("Do shading with light angle (degrees)"); shadeCheckbox.setToolTipText("Use bumpmap shading on the terrain"); shadeCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); shadeCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0)); shadeCheckbox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { shadeCheckboxActionPerformed(evt); } }); shadeAngleSpinner.setModel(new SpinnerNumberModel(150.0, 0.0, 360.0, 0.1)); shadeAngleSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { shadeAngleSpinnerStateChanged(evt); } }); lighterSpinner.setModel(new SpinnerNumberModel(0, 0, 100, 1)); lighterSpinner.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { lighterSpinnerStateChanged(evt); } }); jLabel19.setText("Lighten colours by this amount (doesn't work with alt colours)"); jLabel19.setToolTipText("Use lighter colouring"); outlineCheckbox.setText("Draw in outline mode only"); outlineCheckbox.setToolTipText("Draw a black and white coastline output only"); outlineCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); outlineCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0)); outlineCheckbox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { outlineCheckboxActionPerformed(evt); } }); edgesCheckbox.setText("Draw the edges of coastlines in black"); edgesCheckbox.setToolTipText("Outline the coasts in black"); edgesCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); edgesCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0)); edgesCheckbox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { edgesCheckboxActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout optionsPanelLayout = new org.jdesktop.layout.GroupLayout(optionsPanel); optionsPanel.setLayout(optionsPanelLayout); optionsPanelLayout.setHorizontalGroup(optionsPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(optionsPanelLayout.createSequentialGroup().addContainerGap().add(optionsPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(altColourCheckbox) .add(laticCheckbox) .add(optionsPanelLayout.createSequentialGroup().add(shadeCheckbox) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 304, Short.MAX_VALUE) .add(shadeAngleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(org.jdesktop.layout.GroupLayout.TRAILING, optionsPanelLayout.createSequentialGroup().add(17, 17, 17).add(jLabel19) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 189, Short.MAX_VALUE) .add(lighterSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(optionsPanelLayout.createSequentialGroup().add(17, 17, 17).add(outlineCheckbox)) .add(edgesCheckbox)).addContainerGap())); optionsPanelLayout.setVerticalGroup(optionsPanelLayout .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(optionsPanelLayout.createSequentialGroup().addContainerGap().add(altColourCheckbox) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(laticCheckbox) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(optionsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(shadeCheckbox).add(shadeAngleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(optionsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lighterSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel19)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(edgesCheckbox) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(outlineCheckbox) .addContainerGap(250, Short.MAX_VALUE))); optionsPanelLayout.linkSize(new java.awt.Component[] { altColourCheckbox, laticCheckbox, shadeCheckbox }, org.jdesktop.layout.GroupLayout.VERTICAL); jTabbedPane1.addTab("Options", null, optionsPanel, "Set the rest of the options"); fileMenu.setText("File"); loadParamsItem.setText("Load Settings ..."); loadParamsItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { loadParamsItemActionPerformed(evt); } }); fileMenu.add(loadParamsItem); saveParamsItem.setText("Save Settings ..."); saveParamsItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveParamsItemActionPerformed(evt); } }); fileMenu.add(saveParamsItem); fileMenu.add(jSeparator1); exitItem.setText("Exit ..."); exitItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitItemActionPerformed(evt); } }); fileMenu.add(exitItem); jMenuBar1.add(fileMenu); optionsMenu.setText("Options"); nativeLAFCheckbox.setText("Use system look and feel"); nativeLAFCheckbox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { nativeLAFCheckboxActionPerformed(evt); } }); optionsMenu.add(nativeLAFCheckbox); jMenuBar1.add(optionsMenu); helpMenu.setText("Help"); aboutItem.setText("About ..."); aboutItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { aboutItemActionPerformed(evt); } }); helpMenu.add(aboutItem); jMenuBar1.add(helpMenu); setJMenuBar(jMenuBar1); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup().addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 687, Short.MAX_VALUE)) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup().addContainerGap() .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 416, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap())); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width - 715) / 2, (screenSize.height - 515) / 2, 715, 515); }
From source file:com.vip.saturn.job.console.service.impl.JobDimensionServiceImpl.java
public String geJobRunningInfo(final String jobName) { String serverNodePath = JobNodePath.getServerNodePath(jobName); CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = curatorRepository.inSessionClient(); if (!curatorFrameworkOp.checkExists(serverNodePath)) { return ""; }/* w ww . j a v a2 s. c o m*/ List<String> servers = curatorFrameworkOp.getChildren(serverNodePath); // serverServer?Crashed if (servers == null || servers.size() == 0) { return ""; } int processSuccessCount = 0; int processFailureCount = 0; for (String each : servers) { String processSuccessCountStr = curatorFrameworkOp .getData(JobNodePath.getServerNodePath(jobName, each, "processSuccessCount")); if (!Strings.isNullOrEmpty(processSuccessCountStr)) { processSuccessCount += Integer.parseInt(processSuccessCountStr); } String processFailureCountStr = curatorFrameworkOp .getData(JobNodePath.getServerNodePath(jobName, each, "processFailureCount")); if (!Strings.isNullOrEmpty(processFailureCountStr)) { processFailureCount += Integer.parseInt(processFailureCountStr); } } int count = processSuccessCount; int total = processSuccessCount + processFailureCount; if (total == 0) { return ""; } NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMaximumFractionDigits(2); String result = numberFormat.format((double) count / (double) total * 100); return result + "%"; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.OverlaidBarLine.java
public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); // create the first renderer... CategoryPlot plot = new CategoryPlot(); NumberFormat nf = NumberFormat.getNumberInstance(locale); NumberAxis rangeAxis = new NumberAxis(getValueLabel()); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis/*www.j a va 2 s . c o m*/ .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); // rangeAxis.setLowerBound(600); // rangeAxis.setUpperBound(720); if (firstAxisLB != null && firstAxisUB != null) { rangeAxis.setLowerBound(firstAxisLB); rangeAxis.setUpperBound(firstAxisUB); } rangeAxis.setUpperMargin(0.10); plot.setRangeAxis(0, rangeAxis); if (rangeIntegerValues == true) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } rangeAxis.setNumberFormatOverride(nf); CategoryAxis domainAxis = new CategoryAxis(getCategoryLabel()); domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); domainAxis.setUpperMargin(0.10); plot.setDomainAxis(domainAxis); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); DefaultCategoryDataset datasetLineFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-line"); DefaultCategoryDataset datasetBarFirstAxis = (DefaultCategoryDataset) datasets.getDatasets().get("1-bar"); DefaultCategoryDataset datasetLineSecondAxis = (DefaultCategoryDataset) datasets.getDatasets() .get("2-line"); DefaultCategoryDataset datasetBarSecondAxis = (DefaultCategoryDataset) datasets.getDatasets().get("2-bar"); //I create one bar renderer and one line MyStandardCategoryItemLabelGenerator generator = null; // value labels and additional values are mutually exclusive if (showValueLabels == true) additionalLabels = false; if (additionalLabels) { generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance()); } if (useBars) { CategoryItemRenderer barRenderer = null; if (stackedBarRenderer_1 == true) { barRenderer = new StackedBarRenderer(); } else { barRenderer = new BarRenderer(); } CategoryItemRenderer barRenderer2 = new BarRenderer(); if (stackedBarRenderer_2 == true) { barRenderer2 = new StackedBarRenderer(); } else { barRenderer2 = new BarRenderer(); } if (maxBarWidth != null) { ((BarRenderer) barRenderer).setMaximumBarWidth(maxBarWidth.doubleValue()); ((BarRenderer) barRenderer2).setMaximumBarWidth(maxBarWidth.doubleValue()); } if (showValueLabels) { barRenderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); barRenderer.setBaseItemLabelsVisible(true); barRenderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); barRenderer.setBaseItemLabelPaint(styleValueLabels.getColor()); // barRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); // // barRenderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); if (valueLabelsPosition.equalsIgnoreCase("inside")) { barRenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); barRenderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); } else { barRenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); barRenderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); } } else if (additionalLabels) { barRenderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); barRenderer.setBaseItemLabelGenerator(generator); double orient = (-Math.PI / 2.0); if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) { orient = 0.0; } barRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); barRenderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); barRenderer.setBaseItemLabelFont( new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); barRenderer.setBaseItemLabelPaint(defaultLabelsStyle.getColor()); barRenderer.setBaseItemLabelsVisible(true); } if (showValueLabels) { barRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); barRenderer2.setBaseItemLabelsVisible(true); barRenderer2.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); barRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor()); // barRenderer2.setBasePositiveItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); // // barRenderer2.setBaseNegativeItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); if (valueLabelsPosition.equalsIgnoreCase("inside")) { barRenderer2.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); barRenderer2.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); } else { barRenderer2.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); barRenderer2.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); } } else if (additionalLabels) { barRenderer2.setBaseItemLabelGenerator(generator); double orient = (-Math.PI / 2.0); if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) { orient = 0.0; } barRenderer2.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); barRenderer2.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); barRenderer2.setBaseItemLabelFont( new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); barRenderer2.setBaseItemLabelPaint(defaultLabelsStyle.getColor()); barRenderer2.setBaseItemLabelsVisible(true); } if (colorMap != null) { int idx = -1; for (Iterator iterator = datasetBarFirstAxis.getRowKeys().iterator(); iterator.hasNext();) { idx++; String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetBarFirstAxis.getRowIndex(labelName); } else index = datasetBarFirstAxis.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { barRenderer.setSeriesPaint(index, color); } } for (Iterator iterator = datasetBarSecondAxis.getRowKeys().iterator(); iterator.hasNext();) { idx++; String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetBarSecondAxis.getRowIndex(labelName); } else index = datasetBarSecondAxis.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { barRenderer2.setSeriesPaint(index, color); /* test con un renderer if (idx > index){ index = idx+1; } barRenderer.setSeriesPaint(index, color);*/ } } } // add tooltip if enabled if (enableToolTips) { MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips, seriesTooltip, categoriesTooltip, seriesCaptions); barRenderer.setToolTipGenerator(generatorToolTip); barRenderer2.setToolTipGenerator(generatorToolTip); } //defines url for drill boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true; logger.debug("Calling Url Generation"); MyCategoryUrlGenerator mycatUrl = null; if (super.rootUrl != null) { logger.debug("Set MycatUrl"); mycatUrl = new MyCategoryUrlGenerator(super.rootUrl); mycatUrl.setDocument_composition(document_composition); mycatUrl.setCategoryUrlLabel(super.categoryUrlName); mycatUrl.setSerieUrlLabel(super.serieUrlname); mycatUrl.setDrillDocTitle(drillDocTitle); mycatUrl.setTarget(target); } if (mycatUrl != null && (!mycatUrl.getCategoryUrlLabel().equals("") || !mycatUrl.getSerieUrlLabel().equals(""))) { barRenderer.setItemURLGenerator(mycatUrl); barRenderer2.setItemURLGenerator(mycatUrl); } plot.setDataset(2, datasetBarFirstAxis); plot.setDataset(3, datasetBarSecondAxis); plot.setRenderer(2, barRenderer); plot.setRenderer(3, barRenderer2); } if (useLines) { LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer(); LineAndShapeRenderer lineRenderer2 = new LineAndShapeRenderer(); //lineRenderer.setShapesFilled(false); lineRenderer.setShapesFilled(true); lineRenderer2.setShapesFilled(true); // no shapes for line_no_shapes series for (Iterator iterator = lineNoShapeSeries1.iterator(); iterator.hasNext();) { String ser = (String) iterator.next(); // if there iS a abel associated search for that String label = null; if (seriesLabelsMap != null) { label = (String) seriesLabelsMap.get(ser); } if (label == null) label = ser; int index = datasetLineFirstAxis.getRowIndex(label); if (index != -1) { lineRenderer.setSeriesShapesVisible(index, false); } } for (Iterator iterator = lineNoShapeSeries2.iterator(); iterator.hasNext();) { String ser = (String) iterator.next(); // if there iS a abel associated search for that String label = null; if (seriesLabelsMap != null) { label = (String) seriesLabelsMap.get(ser); } if (label == null) label = ser; int index = datasetLineSecondAxis.getRowIndex(label); if (index != -1) { lineRenderer2.setSeriesShapesVisible(index, false); } } if (enableToolTips) { MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips, seriesTooltip, categoriesTooltip, seriesCaptions); lineRenderer.setToolTipGenerator(generatorToolTip); lineRenderer2.setToolTipGenerator(generatorToolTip); } if (showValueLabels) { lineRenderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); lineRenderer.setBaseItemLabelsVisible(true); lineRenderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.ITALIC, styleValueLabels.getSize())); lineRenderer.setBaseItemLabelPaint(styleValueLabels.getColor()); lineRenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT)); lineRenderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT)); } else if (additionalLabels) { lineRenderer.setBaseItemLabelGenerator(generator); lineRenderer.setBaseItemLabelFont( new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); lineRenderer.setBaseItemLabelPaint(defaultLabelsStyle.getColor()); lineRenderer.setBaseItemLabelsVisible(true); } if (showValueLabels) { lineRenderer2.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); lineRenderer2.setBaseItemLabelsVisible(true); lineRenderer2.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.ITALIC, styleValueLabels.getSize())); lineRenderer2.setBaseItemLabelPaint(styleValueLabels.getColor()); lineRenderer2.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT)); lineRenderer2.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT)); } else if (additionalLabels) { lineRenderer2.setBaseItemLabelGenerator(generator); lineRenderer2.setBaseItemLabelFont( new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); lineRenderer2.setBaseItemLabelPaint(defaultLabelsStyle.getColor()); lineRenderer2.setBaseItemLabelsVisible(true); } // DefaultCategoryDataset datasetSecondAxis=(DefaultCategoryDataset)datasets.getDatasets().get("2"); if (colorMap != null) { for (Iterator iterator = datasetLineSecondAxis.getRowKeys().iterator(); iterator.hasNext();) { String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetLineSecondAxis.getRowIndex(labelName); } else index = datasetLineSecondAxis.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { lineRenderer2.setSeriesPaint(index, color); } } for (Iterator iterator = datasetLineFirstAxis.getRowKeys().iterator(); iterator.hasNext();) { String serName = (String) iterator.next(); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serName; serName = (String) seriesCaptions.get(serName); index = datasetLineFirstAxis.getRowIndex(labelName); } else index = datasetLineFirstAxis.getRowIndex(serName); Color color = (Color) colorMap.get(serName); if (color != null) { lineRenderer.setSeriesPaint(index, color); } } } plot.setDataset(0, datasetLineFirstAxis); plot.setRenderer(0, lineRenderer); plot.setDataset(1, datasetLineSecondAxis); plot.setRenderer(1, lineRenderer2); } if (secondAxis) { NumberAxis na = new NumberAxis(secondAxisLabel); na.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); na.setLabelPaint(styleXaxesLabels.getColor()); na.setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); na.setTickLabelPaint(styleXaxesLabels.getColor()); na.setUpperMargin(0.10); na.setNumberFormatOverride(nf); // rangeAxis.setLowerBound(270); // rangeAxis.setUpperBound(340); if (secondAxisLB != null && secondAxisUB != null) { rangeAxis.setLowerBound(secondAxisLB); rangeAxis.setUpperBound(secondAxisUB); } plot.setRangeAxis(1, na); plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToRangeAxis(2, 0); plot.mapDatasetToRangeAxis(1, 1); plot.mapDatasetToRangeAxis(3, 1); if (rangeIntegerValues == true) { na.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } } //plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); JFreeChart chart = new JFreeChart(plot); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } chart.setBackgroundPaint(Color.white); if (legend == true) drawLegend(chart); logger.debug("OUT"); return chart; }
From source file:de.tor.tribes.ui.views.DSWorkbenchSOSRequestAnalyzer.java
private String buildSimpleRequestTable(Village pTarget, TroopAmountFixed pNeed, DefenseInformation pDefense) { StringBuilder b = new StringBuilder(); SimpleDateFormat df = new SimpleDateFormat("dd.MM.yy HH:mm:ss"); b.append("[table]\n"); b.append("[**]").append(pTarget.toBBCode()); int colCount = 0; for (UnitHolder unit : DataHolder.getSingleton().getUnits()) { int value = pNeed.getAmountForUnit(unit); if (value > 0) { b.append("[|]").append("[unit]").append(unit.getPlainName()).append("[/unit]"); colCount++;// w w w .jav a 2 s . co m } } b.append("[/**]\n"); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(0); nf.setMaximumFractionDigits(0); b.append("[*]"); for (UnitHolder unit : DataHolder.getSingleton().getUnits()) { int value = pNeed.getAmountForUnit(unit); if (value > 0) { b.append("[|]").append(nf.format(value)); } } b.append("[*][b]Angriffe/Fakes:[/b] ").append(pDefense.getAttackCount()).append("/") .append(pDefense.getFakeCount()); for (int i = 0; i < colCount; i++) { b.append("[|]"); } b.append("\n"); b.append("[*][b]Zeitraum:[/b] ").append(df.format(pDefense.getFirstAttack())).append(" bis ") .append(df.format(pDefense.getLastAttack())); for (int i = 0; i < colCount; i++) { b.append("[|]"); } b.append("\n"); b.append("[/table]\n"); return b.toString(); }
From source file:org.squale.squalecommon.enterpriselayer.facade.quality.MeasureFacade.java
/** * Creation d'une mesure de type Kiviat pour un projet * /*ww w .j av a 2s .com*/ * @param pProjectId Id du projet * @param pAuditId Id de l'audit * @param pAllFactors tous les facteurs (= "true") ou seulement ceux ayant une note ? * @throws JrafEnterpriseException en cas de pb Hibernate * @return tableau d'objets : la map des donnes + le boolen pour affichage de la case cocher tous les facteurs */ public static Object[] getProjectKiviat(Long pProjectId, Long pAuditId, String pAllFactors) throws JrafEnterpriseException { Map result = new HashMap(); JFreeChart projectKiviat = null; MeasureDAOImpl measureDAO = MeasureDAOImpl.getInstance(); // Session Hibernate ISession session = null; // Boolen conditonnanant l'affichage de la case cocher "tous les facteurs" dans la page Jsp boolean displayCheckBoxFactors = true; try { // rcupration d'une session session = PERSISTENTPROVIDER.getSession(); // On ajoute les notes de chaque projets sur le kiviat ProjectBO project = (ProjectBO) ProjectDAOImpl.getInstance().load(session, pProjectId); SortedMap values = new TreeMap(); // recupere les facteurs du projet Collection factorResults = QualityResultDAOImpl.getInstance().findWhere(session, pProjectId, pAuditId); // et cree le map nom => note correspondant Iterator it = factorResults.iterator(); ArrayList nullValuesList = new ArrayList(); while (it.hasNext()) { FactorResultBO factor = (FactorResultBO) it.next(); // le -1 est trait directement par le kiviatMaker Float value = new Float(factor.getMeanMark()); // ajoute la note dans le titre // TODO prendre le vritable nom du facteur String name = factor.getRule().getName(); if (value.floatValue() >= 0) { // avec 1 seul chiffre aprs la virgule NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(1); nf.setMaximumFractionDigits(1); name = name + " (" + nf.format(value) + ")"; } else { // Mmorisation temporaire des facteurs pour lesquels les notes sont nulles : sera utile si l'option // "Tous les facteurs" est coche pour afficher uniquement les facteurs ayant une note. nullValuesList.add(name); } values.put(name, value); } final int FACTORS_MIN = 3; if (nullValuesList.size() <= 0 || values.size() <= FACTORS_MIN) { displayCheckBoxFactors = false; } // Seulement les facteurs ayant une note ? ==> suppression des facteurs ayant une note nulle. // Mais trois facteurs doivent au moins s'afficher (nuls ou pas !) values = deleteFactors(values, nullValuesList, pAllFactors, FACTORS_MIN); // recupre le nom de l'audit String name = null; AuditBO audit = (AuditBO) AuditDAOImpl.getInstance().load(session, pAuditId); if (audit.getType().compareTo(AuditBO.MILESTONE) == 0) { name = audit.getName(); } if (null == name) { DateFormat df = DateFormat.getDateInstance(DateFormat.LONG); name = df.format(audit.getDate()); } result.put(name, values); } catch (Exception e) { FacadeHelper.convertException(e, MeasureFacade.class.getName() + ".getMeasures"); } finally { FacadeHelper.closeSession(session, MeasureFacade.class.getName() + ".getMeasures"); } Object[] kiviatObject = { result, new Boolean(displayCheckBoxFactors) }; return kiviatObject; }
From source file:com.glaf.core.jdbc.QueryHelper.java
/** * @param conn/* w w w .j a v a 2 s .c om*/ * ? * @param sqlExecutor * ? * @param start * 0 * @param pageSize * ? * @return */ @SuppressWarnings("unchecked") public List<Map<String, Object>> getResultList(Connection conn, SqlExecutor sqlExecutor, int start, int pageSize) { if (!DBUtils.isLegalQuerySql(sqlExecutor.getSql())) { throw new RuntimeException(" SQL statement illegal "); } List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>(); String sql = sqlExecutor.getSql(); PreparedStatement psmt = null; ResultSet rs = null; ResultSetMetaData rsmd = null; boolean supportsPhysicalPage = false; try { Dialect dialect = DBConfiguration.getDatabaseDialect(conn); if (dialect != null && dialect.supportsPhysicalPage()) { supportsPhysicalPage = true; sql = dialect.getLimitString(sql, start, pageSize); logger.debug("sql=" + sqlExecutor.getSql()); logger.debug(">>sql=" + sql); } psmt = conn.prepareStatement(sql); if (sqlExecutor.getParameter() != null) { List<Object> values = (List<Object>) sqlExecutor.getParameter(); JdbcUtils.fillStatement(psmt, values); logger.debug(">>values=" + values); } rs = psmt.executeQuery(); if (conf.getBoolean("useMyBatisResultHandler", false)) { resultList = this.getResults(rs); } else { rsmd = rs.getMetaData(); int count = rsmd.getColumnCount(); List<ColumnDefinition> columns = new ArrayList<ColumnDefinition>(); for (int i = 1; i <= count; i++) { int sqlType = rsmd.getColumnType(i); ColumnDefinition column = new ColumnDefinition(); column.setIndex(i); column.setColumnName(rsmd.getColumnName(i)); column.setColumnLabel(rsmd.getColumnLabel(i)); column.setJavaType(FieldType.getJavaType(sqlType)); column.setPrecision(rsmd.getPrecision(i)); column.setScale(rsmd.getScale(i)); if (column.getScale() == 0 && sqlType == Types.NUMERIC) { column.setJavaType("Long"); } column.setName(StringTools.camelStyle(column.getColumnLabel().toLowerCase())); columns.add(column); } if (!supportsPhysicalPage) { logger.debug("---------------------skipRows:" + start); this.skipRows(rs, start, pageSize); } logger.debug("---------------------columns:" + columns.size()); logger.debug("---------------------start:" + start); logger.debug("---------------------pageSize:" + pageSize); // int index = 0; while (rs.next()) { // index++; // logger.debug("---------------------row index:" + index); Map<String, Object> rowMap = new HashMap<String, Object>(); Iterator<ColumnDefinition> iterator = columns.iterator(); while (iterator.hasNext()) { ColumnDefinition column = iterator.next(); String columnLabel = column.getColumnLabel(); String columnName = column.getColumnName(); if (StringUtils.isEmpty(columnName)) { columnName = column.getColumnLabel(); } columnName = columnName.toLowerCase(); String javaType = column.getJavaType(); if ("String".equals(javaType)) { String value = rs.getString(column.getIndex()); if (value != null) { value = value.trim(); rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } } else if ("Integer".equals(javaType)) { try { Integer value = rs.getInt(column.getIndex()); rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("integer:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.intValue()); rowMap.put(columnLabel, rowMap.get(columnName)); logger.debug("?:" + num.intValue()); } } else if ("Long".equals(javaType)) { try { Long value = rs.getLong(column.getIndex()); rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("long:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.longValue()); rowMap.put(columnLabel, rowMap.get(columnName)); logger.debug("?:" + num.longValue()); } } else if ("Double".equals(javaType)) { try { Double d = rs.getDouble(column.getIndex()); rowMap.put(columnName, d); rowMap.put(columnLabel, rowMap.get(columnName)); } catch (Exception e) { String str = rs.getString(column.getIndex()); logger.error("double:" + str); str = StringTools.replace(str, "$", ""); str = StringTools.replace(str, "", ""); str = StringTools.replace(str, ",", ""); NumberFormat fmt = NumberFormat.getInstance(); Number num = fmt.parse(str); rowMap.put(columnName, num.doubleValue()); rowMap.put(columnLabel, rowMap.get(columnName)); logger.debug("?:" + num.doubleValue()); } } else if ("Boolean".equals(javaType)) { rowMap.put(columnName, rs.getBoolean(column.getIndex())); rowMap.put(columnLabel, rowMap.get(columnName)); } else if ("Date".equals(javaType)) { rowMap.put(columnName, rs.getTimestamp(column.getIndex())); rowMap.put(columnLabel, rowMap.get(columnName)); } else if ("Blob".equals(javaType)) { } else { Object value = rs.getObject(column.getIndex()); if (value != null) { if (value instanceof String) { value = (String) value.toString().trim(); } rowMap.put(columnName, value); rowMap.put(columnLabel, rowMap.get(columnName)); } } } resultList.add(rowMap); } } logger.debug(">resultList size = " + resultList.size()); return resultList; } catch (Exception ex) { logger.error(ex); ex.printStackTrace(); throw new RuntimeException(ex); } finally { JdbcUtils.close(psmt); JdbcUtils.close(rs); } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.StackedBarGroup.java
/** * Inherited by IChart./* ww w. j a va 2 s. c om*/ * * @param chartTitle the chart title * @param dataset the dataset * * @return the j free chart */ public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1"); logger.debug("Get plot orientaton"); PlotOrientation plotOrientation = PlotOrientation.VERTICAL; if (horizontalView) { plotOrientation = PlotOrientation.HORIZONTAL; } JFreeChart chart = ChartFactory.createStackedBarChart(name, // chart title categoryLabel, // domain axis label valueLabel, // range axis label dataset, // data plotOrientation, // the plot orientation legend, // legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(color); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); KeyToGroupMap map = new KeyToGroupMap("G1"); int numElForGroup = 0; for (int idx = 0; idx < numGroups.intValue(); idx++) { for (int j = 0; j < numSerieForGroup.intValue(); j++) { try { String tmpSubCat = (String) subCategoryNames.get(j + idx * numSerieForGroup.intValue()); map.mapKeyToGroup(tmpSubCat, "G" + (idx + 1)); } catch (Exception e) { logger.error("out of range error in inserting in stacked bar group: continue anayway", e); } } } renderer.setSeriesToGroupMap(map); renderer.setItemMargin(0.0); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); if (percentageValue) renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("#,##.#%"))); else renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); if (maxBarWidth != null) { renderer.setMaximumBarWidth(maxBarWidth.doubleValue()); } boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true; /* MyCategoryUrlGenerator mycatUrl=new MyCategoryUrlGenerator(rootUrl); mycatUrl.setDocument_composition(document_composition); mycatUrl.setCategoryUrlLabel(categoryUrlName); mycatUrl.setSerieUrlLabel(serieUrlname); renderer.setItemURLGenerator(mycatUrl); */ TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(color); NumberFormat nf = NumberFormat.getNumberInstance(locale); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis.setNumberFormatOverride(nf); if (rangeIntegerValues == true) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } if (rangeAxisLocation != null) { if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); } } int seriesN = dataset.getRowCount(); int numSerieColored = 0; if (orderColorVector != null && orderColorVector.size() > 0) { logger.debug("color serie by SERIES_ORDER_COLORS template specification"); for (int i = 0; i < seriesN; i++) { if (orderColorVector.get(i) != null) { Color color = orderColorVector.get(i); renderer.setSeriesPaint(i, color); } } } else if (colorMap != null) { while (numSerieColored < seriesN) { for (int i = 1; i <= colorMap.size(); i++) { Color color = (Color) colorMap.get("SER" + i); Color gradient = new Color(Integer.decode("#FFFFFF").intValue()); if (gradientMap != null) gradient = (Color) gradientMap.get("SER" + i); if (color != null) { Paint p = new GradientPaint(0.0f, 0.0f, color, 0.0f, 0.0f, gradient); //renderer.setSeriesPaint(numSerieColored, color); renderer.setSeriesPaint(numSerieColored, p); } numSerieColored++; } } } renderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); MyStandardCategoryItemLabelGenerator generator = null; if (additionalLabels) { generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance()); double orient = (-Math.PI / 2.0); if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) { orient = 0.0; } renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); //vertical labels renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); renderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, orient)); //horizontal labels /* renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition( ItemLabelAnchor.CENTER, TextAnchor.CENTER)); */ } SubCategoryAxis domainAxis = new SubCategoryAxis(categoryLabel + " / " + subCategoryLabel); String subCatLabel = ""; for (int j = 1; j <= numGroups.intValue(); j++) { if (subCatLabelsMap != null) subCatLabel = (String) subCatLabelsMap.get("CAT" + j); else subCatLabel = subCategoryLabel; domainAxis.addSubCategory(subCatLabel); domainAxis .setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis.setTickLabelFont( new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); } plot.setDomainAxis(domainAxis); plot.setRenderer(renderer); /* domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions( Math.PI / 6.0)); */ if (legend == true) drawLegend(chart); logger.debug("OUT"); return chart; }