@Test public void testDataReadable() { // Init Number Serices Services.initNumberFormats(); XMLImport myImport = new XMLImport("src/org/bh/companydata/periods.xml"); try { DTOBusinessData myDTO = (DTOBusinessData) myImport.startImport(); List<DTOBranch> branches = myDTO.getChildren(); File f = new File("BROKEN_DATA.data"); System.out.println(f.getAbsolutePath()); PrintWriter outputStream = new PrintWriter(f); for (DTOBranch branch : branches) { for (DTOCompany company : branch.getChildren()) { DTOScenario scenario = new DTOScenario(); scenario.put(DTOScenario.Key.BTAX, new DoubleValue(10.0)); scenario.put(DTOScenario.Key.REK, new DoubleValue(10.0)); scenario.put(DTOScenario.Key.RFK, new DoubleValue(10.0)); scenario.put(DTOScenario.Key.CTAX, new DoubleValue(10.0)); company.updateReferences(scenario); int i = 0; for (DTOPeriod period : company.getChildren()) { try { if (i != 0) { period.get(DTOPeriod.Key.FCF); } period.get(DTOPeriod.Key.LIABILITIES); } catch (DTOAccessException ae) { ae.printStackTrace(outputStream); outputStream.println(branch + " " + company + " " + period); } i++; } } } outputStream.close(); } catch (Exception e) { e.printStackTrace(); fail(); } }
public void testImport() { // Init Number Serices Services.initNumberFormats(); XMLImport myImport = new XMLImport("src/org/bh/companydata/periods.xml"); try { DTOBusinessData myDTO = (DTOBusinessData) myImport.startImport(); // // just play with the BusinessData DTO! :-) // Like... // int counter = 0; List<DTOBranch> branchList = myDTO.getChildren(); // Iterate all Company DTOs Iterator<DTOBranch> itr = branchList.iterator(); while (itr.hasNext()) { DTOBranch currBranch = itr.next(); // echos the branch keys System.out.print(currBranch.get(DTOBranch.Key.BRANCH_KEY_MAIN_CATEGORY)); System.out.print(currBranch.get(DTOBranch.Key.BRANCH_KEY_MID_CATEGORY)); System.out.println(currBranch.get(DTOBranch.Key.BRANCH_KEY_SUB_CATEGORY)); // // Do the Branch has Companies? List<DTOCompany> companyList = currBranch.getChildren(); Iterator<DTOCompany> CompanyItr = companyList.iterator(); while (CompanyItr.hasNext()) { DTOCompany currCompany = CompanyItr.next(); // echo them System.out.println("----" + currCompany.get(DTOCompany.Key.NAME)); // // Do the Company has any Periods? List<DTOPeriod> periodList = currCompany.getChildren(); Iterator<DTOPeriod> PeriodItr = periodList.iterator(); while (PeriodItr.hasNext()) { DTOPeriod currPeriod = PeriodItr.next(); // echo the name of the Period System.out.println("---------" + currPeriod.get(DTOPeriod.Key.NAME)); counter++; // // NEW ENHANCEMENT 04.01.2012 // // get the Balance Sheet DTOGCCBalanceSheet myCurrBalanceSheet = (DTOGCCBalanceSheet) currPeriod.getChild(0); // // TotalCosts or CostOfSales Method? // get the ProfitLossStatements IPeriodicalValuesDTO myProfitStatement = currPeriod.getChild(1); // TotalCost Method if (myProfitStatement.getUniqueId() == DTOGCCProfitLossStatementTotalCost.getUniqueIdStatic()) { DTOGCCProfitLossStatementTotalCost myProfitStatementCasted = (DTOGCCProfitLossStatementTotalCost) myProfitStatement; } // CostOfSales Method if (myProfitStatement.getUniqueId() == DTOGCCProfitLossStatementCostOfSales.getUniqueIdStatic()) { DTOGCCProfitLossStatementCostOfSales myProfitStatementCasted = (DTOGCCProfitLossStatementCostOfSales) myProfitStatement; } } } } System.out.println(counter); } catch (XMLNotValidException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void initialize() { this.setLayout(new GridBagLayout()); d = new GridBagConstraints(); distributionChart = BHChartFactory.getXYBarChart(BHBSRStochasticResultController.ChartKeys.DISTRIBUTION_CHART); cashflowChart = BHChartFactory.getLineChart(BHBSRStochasticResultController.ChartKeys.CASHFLOW_CHART); cashflowChartCompare = BHChartFactory.getLineChart( BHBSRStochasticResultController.ChartKeys.CASHFLOW_CHART_COMPARE); XYPlot plot = cashflowChart.getChart().getXYPlot(); IntervalMarker target = new IntervalMarker(0.0, 500.0); target.setLabel( Services.getTranslator() .translate(BHBSRStochasticResultController.ChartKeys.CASHFLOW_FORECAST)); target.setLabelAnchor(RectangleAnchor.BOTTOM); target.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); target.setLabelFont(new Font("SansSerif", Font.ITALIC, 20)); target.setPaint(new Color(222, 222, 255, 128)); plot.addDomainMarker(target, Layer.BACKGROUND); XYPlot plot2 = cashflowChartCompare.getChart().getXYPlot(); plot2.getRenderer().setSeriesPaint(0, Color.red); plot2.getRenderer().setSeriesPaint(1, Color.blue); BHDescriptionLabel sd = new BHDescriptionLabel("standardDeviation"); BHDescriptionLabel ew = new BHDescriptionLabel((BHBSRStochasticResultController.PanelKeys.AVERAGE)); BHValueLabel sdValue = new BHValueLabel((BHBSRStochasticResultController.ChartKeys.STANDARD_DEVIATION)); BHValueLabel ewValue = new BHValueLabel((BHBSRStochasticResultController.ChartKeys.AVERAGE).toString()); BHDescriptionLabel riskAt = new BHDescriptionLabel(BHBSRStochasticResultController.ChartKeys.RISK_AT_VALUE); BHSlider slider = new BHSlider(BHBSRStochasticResultController.ChartKeys.RISK_AT_VALUE, 0, 100, 95); BHSlider sliderRatio = new BHSlider(BHBSRStochasticResultController.ChartKeys.BSR_RATIO, 0, 100, 0); BHSlider slider_cashflow = new BHSlider(BHBSRStochasticResultController.ChartKeys.CASHFLOW_COMPARE_SLIDER); slider_cashflow.setMinimum(3); slider_cashflow.setValue(3); slider_cashflow.setMajorTickSpacing(2); slider_cashflow.setMinorTickSpacing(1); slider_cashflow.setPaintTicks(true); slider_cashflow.setPaintLabels(true); BHDescriptionLabel min = new BHDescriptionLabel("min"); BHDescriptionLabel max = new BHDescriptionLabel("max"); BHDescriptionLabel choose_p = new BHDescriptionLabel(BHBSRStochasticResultController.PanelKeys.COMPARE_P); BHValueLabel minValue = new BHValueLabel(BHBSRStochasticResultController.ChartKeys.RISK_AT_VALUE_MIN); BHValueLabel maxValue = new BHValueLabel(BHBSRStochasticResultController.ChartKeys.RISK_AT_VALUE_MAX); BHDescriptionLabel RatioDesc = new BHDescriptionLabel(BHBSRStochasticResultController.PanelKeys.RATIO); JPanel rav = new JPanel(); rav.setLayout( new FormLayout( // "4px:grow,right:pref,10px,pref,4px,pref,4px:grow", // "pref,4px,p,4px,p,4px,p,4px,p,4px,p,4px,p,4px)); "right:pref" // Column 1 + ", 3dlu" // Column 2 + ", fill:max(100dlu;pref):grow" // Column 3 + ", 3dlu" // Column 4 + ", right:pref" // Column 5 + ", 3dlu" // Column 6 // // + ", fill:max(100dlu;pref):grow" //Column 6 // + ", pref" //Column 7 // + ", 3dlu" //Column 8 // + ", max(100dlu;pref)" //Column 9 // + ", 3dlu" //Column 10 // + ", pref" //Column 11 // + ", 3dlu" //Column 12 // + ", 4px:grow" //Column 13 // + ", 3dlu" //Column 14 , "pref" // Row 1 + ",4px" // Row 2 + ",p" // Row 3 + ",4px" // Row 4 + ",p" // Row 5 + ",4px" // Row 6 + ",p" // Row 7 + ",4px" // Row 8 + ",p" // Row 9 + ",4px" // Row 10 + ",p" // Row 11 + ",4px" // Row 12 + ",p" // Row 13 + ",4px")); // Row 14 // Panel with Min and Max calculated by Risk at Value JPanel result = new JPanel(); result.setLayout( new FormLayout( "2dlu" // Column 1 + ", pref" // Column 2 + ", 2dlu" // Column 3 + ", right:max(100dlu;pref):grow" // Column 4 + ", 2dlu" // Column 5 + ", right:pref" // Column 6 + ", 2dlu" // Column 7 , " 2dlu" // Row 1 + ", pref" // Row 2 + ", 2dlu" // Row 3 + ", p" // Row 4 + ", 2dlu" // Row 5 + ", p" // Row 4 + ", 2dlu" // Row 5 + ", p" // Row 4 + ", 2dlu" // Row 5 )); // Panel with expected value and std. deviation JPanel p_sd_ew = new JPanel(); // p_sd_ew.setLayout(new FormLayout( // "2dlu" //Column 1 // + ", pref" //Column 2 // + ", 2dlu" //Column 3 // + ", right:max(100dlu;pref):grow" //Column 4 // + ", 2dlu" //Column 5 // + ", right:pref" //Column 6 // + ", 2dlu" //Column 7 // , // "2dlu" // Row 1 // + ", pref" // Row 2 // + ", 2dlu" // Row 3 // + ", p" // Row 4 // + ", 2dlu" // Row 5 // )); // riskAtField.setPreferredSize(new // Dimension(50,riskAtField.getPreferredSize().height)); slider.setPreferredSize(new Dimension(200, slider.getPreferredSize().height)); sliderRatio.setPreferredSize(new Dimension(200, sliderRatio.getPreferredSize().height)); // ValidationRule[] rules = {VRIsDouble.INSTANCE, // VRIsBetween.BETWEEN0AND100};//Validation for value at risk // riskAtField.setValidationRules(rules); rav.add(riskAt, "1,3"); rav.add(slider, "3,3"); rav.add(new JLabel("%"), "5,3"); rav.add(RatioDesc, "1,7"); rav.add(sliderRatio, "3,7"); rav.add(new JLabel("%"), "5,7"); result.add(min, "2,6"); result.add(minValue, "4,6"); result.add( new BHDescriptionLabel("currency"), "6,6"); // AWussler replaced: 3.12.2010: Now its translatable result.add(max, "2,8"); result.add(maxValue, "4,8"); result.add( new BHDescriptionLabel("currency"), "6,8"); // AWussler replaced: 3.12.2010: Now its translatable rav.setBorder( BHBorderFactory.getInstacnce() .createTitledBorder( BHBorderFactory.getInstacnce().createEtchedBorder(EtchedBorder.LOWERED), BHBSRStochasticResultController.ChartKeys.SELECTION, TitledBorder.LEFT, TitledBorder.DEFAULT_JUSTIFICATION)); result.setBorder( BHBorderFactory.getInstacnce() .createTitledBorder( BHBorderFactory.getInstacnce().createEtchedBorder(EtchedBorder.LOWERED), BHBSRStochasticResultController.ChartKeys.SELECTION, TitledBorder.LEFT, TitledBorder.DEFAULT_JUSTIFICATION)); // p_sd_ew.setBorder(BHBorderFactory.getInstacnce().createTitledBorder( // BHBorderFactory.getInstacnce().createEtchedBorder( // EtchedBorder.LOWERED), // BHBSRStochasticResultController.ChartKeys.SELECTION, // TitledBorder.LEFT, TitledBorder.DEFAULT_JUSTIFICATION)); compare_p = new JPanel(); compare_p.setLayout(new GridBagLayout()); compare_p.setBorder( BHBorderFactory.getInstacnce() .createTitledBorder( BHBorderFactory.getInstacnce().createEtchedBorder(EtchedBorder.LOWERED), BHBSRStochasticResultController.ChartKeys.COMPARE_P_HEAD, TitledBorder.LEFT, TitledBorder.DEFAULT_JUSTIFICATION)); d.gridx = 0; d.gridy = 0; compare_p.add(choose_p); d.gridx = 0; d.gridy = 1; compare_p.add(slider_cashflow); d.fill = GridBagConstraints.HORIZONTAL; d.gridx = 0; d.gridy = 0; d.insets = new Insets(30, 10, 0, 0); this.add(distributionChart, d); // this.add(distributionChart, "1,3,5,3"); /** * AWussler added: 3.12.2010 put sd and ew (standardabweichung, erwartungswert) in a panel box: */ // JPanel p_sd_ew = new JPanel(); // p_sd_ew.setLayout(new GridLayout(2, 3)); // Gridlayout: 2 rows, 3 // // columns // add first row: result.add(sd, "2,2"); result.add(sdValue, "4,2"); result.add(new BHDescriptionLabel("currency"), "6,2"); // add second row: result.add(ew, "2,4"); result.add(ewValue, "4,4"); result.add(new BHDescriptionLabel("currency"), "6,4"); p_sd_ew.setBorder( BHBorderFactory.getInstacnce() .createEtchedBorder(EtchedBorder.LOWERED)); // set untitled Border // end: AWussler added: 3.12.2010 /* * AWussler removed and replaced: 3.12.2010: instead of adding each * Label add the new panel containing all labels: this.add(sd, "1,5"); * this.add(sdValue, "3,5"); this.add(new JLabel("GE"), "5,5"); * * this.add(ew, "1,7"); this.add(ewValue, "3,7"); this.add(new * JLabel("GE"), "5,7"); */ // d.fill = GridBagConstraints.HORIZONTAL; // d.gridx = 0; // d.gridy = 1; // d.insets = new Insets(10, 10, 0, 0); // this.add(p_sd_ew, d); // this.add(p_sd_ew, "1,5,3,7");//first and second number: coordinate // (x,y) of upper left corner, first and second number: coordinate (x,y) // of under right corner // end: AWussler removed and replaced: 3.12.2010 d.fill = GridBagConstraints.HORIZONTAL; d.gridx = 0; d.gridy = 3; d.insets = new Insets(10, 10, 0, 0); this.add(rav, d); d.fill = GridBagConstraints.HORIZONTAL; d.gridx = 0; d.gridy = 2; d.insets = new Insets(5, 5, 0, 0); this.add(result, d); space = new JLabel(); d.fill = GridBagConstraints.HORIZONTAL; d.gridx = 1; d.gridy = 0; d.weightx = 1.0; d.insets = new Insets(0, 0, 0, 0); this.add(space, d); // this.add(p_sd_ew, "1,5,3,7"); }