Commits

Anonymous committed 19f86b3

収量比較数の変化を描画する機能を追加

Comments (0)

Files changed (5)

build/built-jar.properties

-#Fri, 30 Mar 2012 19:47:52 +0900
+#Fri, 30 Mar 2012 20:24:24 +0900
 
 
 D\:\\yamamon=

src/YaMaMon/DensityNumGraph.java

         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
          */
-        try {
-            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
-                if ("Nimbus".equals(info.getName())) {
-                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
-                    break;
-                }
-            }
-        } catch (ClassNotFoundException ex) {
-            java.util.logging.Logger.getLogger(DensityGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
-        } catch (InstantiationException ex) {
-            java.util.logging.Logger.getLogger(DensityGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
-        } catch (IllegalAccessException ex) {
-            java.util.logging.Logger.getLogger(DensityGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
-        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
-            java.util.logging.Logger.getLogger(DensityGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
-        }
+//        try {
+//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+//                if ("Nimbus".equals(info.getName())) {
+//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
+//                    break;
+//                }
+//            }
+//        } catch (ClassNotFoundException ex) {
+//            java.util.logging.Logger.getLogger(DensityGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+//        } catch (InstantiationException ex) {
+//            java.util.logging.Logger.getLogger(DensityGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+//        } catch (IllegalAccessException ex) {
+//            java.util.logging.Logger.getLogger(DensityGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+//            java.util.logging.Logger.getLogger(DensityGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+//        }
         //</editor-fold>
 
         /* Create and display the form */

src/YaMaMon/MainFrame.java

     private HeightGraph  heightgraph ;
     private VolumeGraph  volumeGraph ;
     private DensityNumGraph densityGraph;
+    private RyGraph ryGraph;
     
     private  class NumericFIeld extends TextField {
         private int column, length;
     }//GEN-LAST:event_densityButtonpredictVolumePerformed
 
     private void RyButtonpredictVolumePerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RyButtonpredictVolumePerformed
-        // TODO add your handling code here:
+        ArrayList<Integer> ageList   = new ArrayList<Integer>();
+        ArrayList<Integer> ratioList = new ArrayList<Integer>();
+
+        metaforest.setAge(Integer.valueOf(ageField.getText()).intValue());
+    metaforest.setHeight(Integer.valueOf(heightField.getText()).intValue());
+    metaforest.setDbh(Integer.valueOf(dbhField.getText()).intValue());
+    metaforest.setDensity(Integer.valueOf(densityField.getText()).intValue());
+    
+    if(!thinRatioField1.getText().equals("") && !thinAgeField1.getText().equals("")){
+        ageList.add(Integer.valueOf(thinAgeField1.getText()).intValue());
+        ratioList.add(Integer.valueOf(thinRatioField1.getText()).intValue());
+    }
+
+    if(!thinRatioField2.getText().equals("") && !thinAgeField2.getText().equals("")){
+       ageList.add(Integer.valueOf(thinAgeField2.getText()).intValue());
+        ratioList.add(Integer.valueOf(thinRatioField2.getText()).intValue());
+    }
+
+    if(!thinRatioField3.getText().equals("") && !thinAgeField3.getText().equals("")){
+        ageList.add(Integer.valueOf(thinAgeField3.getText()).intValue());
+        ratioList.add(Integer.valueOf(thinRatioField3.getText()).intValue());
+    }
+
+    if(!thinRatioField4.getText().equals("") && !thinAgeField4.getText().equals("")){
+        ageList.add(Integer.valueOf(thinAgeField4.getText()).intValue());
+        ratioList.add(Integer.valueOf(thinRatioField4.getText()).intValue());
+    }
+
+    if(!thinRatioField5.getText().equals("") && !thinAgeField5.getText().equals("")){
+        ageList.add(Integer.valueOf(thinAgeField5.getText()).intValue());
+        ratioList.add(Integer.valueOf(thinRatioField5.getText()).intValue());
+    }
+
+    //配列に変換
+    Integer[] ageArray = (Integer[])ageList.toArray(new Integer[0]); 
+    Integer[] ratioArray = (Integer[])ratioList.toArray(new Integer[0]); 
+
+    metaforest.setAgeArray(ageArray);
+    metaforest.setRatioArray(ratioArray);
+    
+    ryGraph = new RyGraph(metaforest);
+    ryGraph.setVisible(true);
     }//GEN-LAST:event_RyButtonpredictVolumePerformed
 
     private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

src/YaMaMon/RyGraph.form

+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <NonVisualComponents>
+    <Component class="YaMaMon.MetaForest" name="metaforest">
+      <AuxValues>
+        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="metaforest.clone();"/>
+      </AuxValues>
+    </Component>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="3"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="400" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="300" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+</Form>

src/YaMaMon/RyGraph.java

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * HeightGraph.java
+ *
+ * Created on 2011/08/04, 14:56:53
+ */
+package YaMaMon;
+
+import org.jfree.chart.axis.ValueAxis;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.ChartFactory;
+//Jfreechartでの文字化け対策
+import org.jfree.chart.StandardChartTheme;
+import javax.swing.JFrame;
+import java.awt.BorderLayout;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.function.Function2D;
+//import org.jfree.data.general.DatasetUtilities;
+import org.jfree.data.xy.XYDataset;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
+
+
+import static java.lang.Math.* ;
+
+
+/**
+ *
+ * @author Maeda Yuhei
+ */
+public class RyGraph extends javax.swing.JFrame {
+    
+    /**
+     * XYDatasetのオブジェクト作成
+     */
+    public final XYDataset createXYDataset(MetaForest metaforest) {
+        if (metaforest == null) throw new NullPointerException("metaforest is null");
+        this.metaforest = metaforest;
+
+        XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
+	XYSeries xySeries;
+        xySeries = new XYSeries("林分材積");
+        double age = metaforest.getAge();
+        double dbh = metaforest.getDbh();
+        double height = metaforest.getHeight();
+        double density = metaforest.getDensity();
+      //  double height;
+        double estVolume;
+        Integer[] ageArray = metaforest.getAgeArray();
+        Integer[] ratioArray = metaforest.getratioArray();
+        
+        //     System.out.println(ratioArray[0]);
+        //     System.out.println(ratioArray[1]);
+        //     System.out.println(ratioArray[2]);
+        
+        
+        double paramC = 1.9d;
+        double paramB = -0.032d;
+        double paramA = height / Math.pow( (1 - exp(paramB * age)), paramC);
+        int thinFlag = 0;
+        double Ry;
+        double diffRy;
+        double ratioDead;
+        
+        for (double incAge = age ; incAge < 100; incAge++) {
+
+            Ry =(0.068509 
+                    * Math.pow(height,-1.347464)
+                    + 2658.2 * Math.pow(height, -2.814651)
+                    / Math.pow(10, 5.3083) * Math.pow(height, -1.4672))
+                    / (0.068509 * Math.pow(height, -1.347464) + 2658.2
+                    * Math.pow(height, -2.814651) / density);
+            
+            //System.out.println(ageArray[thinFlag]);
+            //System.out.println((int)incAge);
+            //System.out.println(ageArray.length >= thinFlag + 1);
+            if(ageArray.length >= thinFlag + 1){
+                if(ageArray[thinFlag].equals((int)incAge) ){
+                    density = density * (100 - ratioArray[thinFlag]) / 100;
+                    //System.out.println("間伐林齢" + density);
+                    thinFlag++;
+                }
+            }
+            
+            height = paramA * Math.pow((1 - exp(paramB * incAge)), paramC);
+            
+
+            
+            estVolume = density 
+                    * Math.pow(10d, (-4.203818 + 1.819629 * Math.log10(dbh)
+                    + 1.025738 * Math.log10(height)));
+        
+
+            System.out.println("収量比数: " + Ry);
+            
+            xySeries.add(incAge, Ry);
+   
+            dbh = dbh
+                    + (3.06915 * exp(-1 * 0.022311 * incAge)
+                    + 2.8 * (4.8042 - Math.log10(density)
+                    - 1.3136 * Math.log10(dbh)));
+          //  System.out.println(estVolume);
+          //  System.out.println(height);
+            System.out.println(density);        
+        }
+
+        xySeriesCollection.addSeries(xySeries);
+        return xySeriesCollection;
+    }
+    
+    
+    /** Creates new form VolumeGraph */
+    public RyGraph(MetaForest metaforest) {
+        if (metaforest == null) throw new NullPointerException("metaforest is null");
+        this.metaforest = metaforest;
+
+        final double age = metaforest.getAge();
+        final double height = metaforest.getHeight();
+    // 無名クラス
+
+    //Jfreechartでの文字化け対策
+    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
+
+    double xmin = 0.0d;
+    double xmax = 100.0d;
+
+    String seriesKey = "樹高";
+
+    //XYDataset dataset = DatasetUtilities.sampleFunction2D(cosh, xmin, xmax, 1000, seriesKey);
+    XYDataset dataset = createXYDataset(metaforest);
+    JFreeChart chart = 
+            ChartFactory.createXYLineChart("材積成長の変化", "林齢", "林分材積", dataset, PlotOrientation.VERTICAL, true, true, false);
+    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+    XYPlot xyPlot = chart.getXYPlot();
+    ValueAxis yAxis = xyPlot.getRangeAxis();
+    yAxis.setAutoRange(false);
+    yAxis.setRange(0.0, 1.0);
+    ValueAxis xAxis = xyPlot.getDomainAxis();
+    xAxis.setAutoRange(false);
+    xAxis.setRange(0,100);
+    setBounds(10, 10, 400, 300);
+    setTitle("材積成長の変化");
+
+    ChartPanel cpanel = new ChartPanel(chart);
+    getContentPane().add(cpanel, BorderLayout.CENTER);
+    }
+
+    /** 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() {
+
+        metaforest = metaforest.clone();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 400, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 300, Short.MAX_VALUE)
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        /* Set the Nimbus look and feel */
+        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
+        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
+         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+         */
+        try {
+            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+                if ("Nimbus".equals(info.getName())) {
+                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
+                    break;
+                }
+            }
+        } catch (ClassNotFoundException ex) {
+            java.util.logging.Logger.getLogger(RyGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+        } catch (InstantiationException ex) {
+            java.util.logging.Logger.getLogger(RyGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+        } catch (IllegalAccessException ex) {
+            java.util.logging.Logger.getLogger(RyGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+            java.util.logging.Logger.getLogger(RyGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+        }
+        //</editor-fold>
+
+        /* Create and display the form */
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            @Override
+            public void run() {
+               // new HeightGraph().setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private YaMaMon.MetaForest metaforest;
+    // End of variables declaration//GEN-END:variables
+}