|
From: <de...@us...> - 2013-08-26 14:15:44
|
Revision: 8469
http://sourceforge.net/p/fudaa/svn/8469
Author: deniger
Date: 2013-08-26 14:15:41 +0000 (Mon, 26 Aug 2013)
Log Message:
-----------
CRUE-545
Modified Paths:
--------------
trunk/soft/fudaa-crue/pom.xml
trunk/soft/fudaa-crue/ui-report/pom.xml
trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/config/AbstractReportGrapheBuilder.java
trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/config/CourbeColorFinder.java
trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/longitudinal/ReportLongitudinalGrapheBuilder.java
trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/multivar/ReportMultiVarGrapheBuilder.java
trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/rptg/ReportRPTGGrapheBuilder.java
trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/temporal/ReportTemporalGrapheBuilder.java
trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/transversal/ReportTransversalGrapheBuilder.java
trunk/soft/fudaa-crue/ui-wrapper/pom.xml
Modified: trunk/soft/fudaa-crue/pom.xml
===================================================================
--- trunk/soft/fudaa-crue/pom.xml 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/pom.xml 2013-08-26 14:15:41 UTC (rev 8469)
@@ -100,6 +100,11 @@
<version>1.07.00</version>
</dependency>
<dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ <version>3.9</version>
+ </dependency>
+ <dependency>
<groupId>org.fudaa.soft.fudaa-crue</groupId>
<artifactId>crue-io</artifactId>
<version>${project.version}</version>
Modified: trunk/soft/fudaa-crue/ui-report/pom.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-report/pom.xml 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-report/pom.xml 2013-08-26 14:15:41 UTC (rev 8469)
@@ -44,6 +44,10 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<scope>provided</scope>
Modified: trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/config/AbstractReportGrapheBuilder.java
===================================================================
--- trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/config/AbstractReportGrapheBuilder.java 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/config/AbstractReportGrapheBuilder.java 2013-08-26 14:15:41 UTC (rev 8469)
@@ -239,6 +239,8 @@
}
+ protected abstract Collection<EGCourbePersist> getCachedCourbeConfig(Z content);
+
public void applyChange(Z content) {
List<EGCourbeSimple> internCourbes = getInternCourbes(content);
loadExternFilesAndAllToModel(content, internCourbes);
@@ -255,7 +257,7 @@
}
}
}
- new CourbeColorFinder().findNewColor(uiController.getGraphe());
+ new CourbeColorFinder().findNewColor(uiController.getGraphe(), CourbeColorFinder.createUsedColor(getCachedCourbeConfig(content)));
uiController.getGraphe().restore();
uiController.getGraphe().fullRepaint();
}
Modified: trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/config/CourbeColorFinder.java
===================================================================
--- trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/config/CourbeColorFinder.java 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/config/CourbeColorFinder.java 2013-08-26 14:15:41 UTC (rev 8469)
@@ -6,20 +6,31 @@
import gnu.trove.TIntHashSet;
import java.awt.Color;
import java.io.File;
+import java.io.FileInputStream;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
-import jxl.Cell;
-import jxl.Sheet;
-import jxl.Workbook;
-import jxl.format.Colour;
-import jxl.format.RGB;
+import java.util.Map;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.hssf.util.HSSFColor;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFColor;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.fudaa.ctulu.CtuluLibFile;
import org.fudaa.ebli.courbe.EGCourbe;
+import org.fudaa.ebli.courbe.EGCourbePersist;
import org.fudaa.ebli.courbe.EGGraphe;
+import org.fudaa.ebli.palette.BPalettePlageAbstract;
import org.fudaa.ebli.palette.BPalettePlageDefault;
import org.fudaa.fudaa.crue.options.services.InstallationService;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
/**
*
@@ -29,12 +40,12 @@
public static Color NONE = new Color(255, 255, 255, 0);
public static long colorIndexeslastTimeModified = -1;
- List<Color> siteColors;
+ private static List<Color> siteColors;
InstallationService installationService = Lookup.getDefault().lookup(InstallationService.class);
private List<Color> getSiteColors() {
File siteDir = installationService.getSiteDir();
- File colors = new File(siteDir, "default-colors.xls");
+ File colors = new File(siteDir, "default-colors.xlsx");
if (colors.isFile()) {
if (siteColors != null && colors.lastModified() <= colorIndexeslastTimeModified) {
return siteColors;
@@ -46,9 +57,26 @@
return Collections.emptyList();
}
- public void findNewColor(EGGraphe graphe) {
+ public static TIntHashSet createUsedColor(Collection<EGCourbePersist> courbeConfigs) {
+ TIntHashSet res = new TIntHashSet();
+ if (courbeConfigs != null) {
+ for (EGCourbePersist config : courbeConfigs) {
+ Color couleur = config.getLineModel_().getCouleur();
+ if (couleur != null) {
+ res.add(couleur.getRGB());
+ }
- TIntHashSet usedColors = new TIntHashSet();
+ }
+ }
+ return res;
+ }
+
+ public void findNewColor(EGGraphe graphe, TIntHashSet initUsedColor) {
+
+ TIntHashSet usedColors = initUsedColor;
+ if (usedColors == null) {
+ usedColors = new TIntHashSet();
+ }
List<EGCourbe> toModify = new ArrayList<EGCourbe>();
if (graphe != null) {
EGCourbe[] courbes = graphe.getModel().getCourbes();
@@ -77,41 +105,87 @@
return siteColor;
}
}
+ double dx = 0.1;
+ double v = 0;
+ //200 essais:
for (int i = 0; i < 200; i++) {
- Color color = BPalettePlageDefault.getColor(i);
+ if (v >= 1d) {
+ v = Math.random();
+ }
+ Color color = BPalettePlageAbstract.getCouleur(Color.red, Color.magenta, v);
if (!used.contains(color.getRGB())) {
return color;
}
+ v = v + dx;
}
return null;
}
private List<Color> loadColors(File file) {
List<Color> colors = new ArrayList<Color>();
- Workbook workbook = null;
+ FileInputStream input = null;
+ Map<Integer, HSSFColor> indexedColors = HSSFColor.getIndexHash();
try {
- workbook = Workbook.getWorkbook(file);
- Sheet sheet = workbook.getSheet(0);
- int row = sheet.getRows();
- if (sheet.getColumns() == 0) {
+ input = new FileInputStream(file);
+
+ XSSFWorkbook workbook = new XSSFWorkbook(input);
+ XSSFSheet sheet = workbook.getSheet("Curves");
+ if (sheet == null) {
return colors;
}
- for (int i = 0; i < row; i++) {
- Cell cell = sheet.getCell(0, i);
- Colour backgroundColour = cell.getCellFormat().getBackgroundColour();
- if (backgroundColour != null) {
- final RGB defaultRGB = backgroundColour.getDefaultRGB();
- colors.add(new Color(defaultRGB.getRed(), defaultRGB.getGreen(), defaultRGB.getBlue()));
+ for (Iterator<Row> it = sheet.rowIterator(); it.hasNext();) {
+ Row row = it.next();
+ if (row.getLastCellNum() > 0) {
+ Cell cell = row.getCell(0);
+ if (cell != null) {
+ final XSSFCellStyle cellStyle = (XSSFCellStyle) cell.getCellStyle();
+ XSSFColor xssfColor = cellStyle.getFillForegroundXSSFColor();
+ Color res = null;
+ if (xssfColor != null && xssfColor.getCTColor() != null) {
+ CTColor ctColor = xssfColor.getCTColor();
+ if (ctColor.isSetIndexed()) {
+ HSSFColor hssfColor = indexedColors.get(Integer.valueOf(xssfColor.getIndexed()));
+ if (hssfColor != null) {
+ res = createColor(hssfColor.getTriplet());
+ }
+
+ } else if (ctColor.isSetTheme()) {
+ xssfColor = workbook.getTheme().getThemeColor(xssfColor.getTheme());
+ if (xssfColor != null) {
+ res = createColor(xssfColor.getARGBHex());
+ }
+ } else {
+ res = createColor(xssfColor.getARGBHex());
+ }
+ if (res != null) {
+ colors.add(res);
+ }
+ }
+ }
}
}
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
} finally {
- if (workbook != null) {
- workbook.close();
- }
+ CtuluLibFile.close(input);
}
return colors;
}
+
+ private static Color createColor(short[] rgb) {
+ if (rgb == null) {
+ return null;
+ }
+ return new Color(rgb[0], rgb[1], rgb[2]);
+ }
+
+ private static Color createColor(String argex) {
+ String substring = StringUtils.substring(argex, 2);
+ try {
+ return Color.decode("#" + substring);
+ } catch (NumberFormatException numberFormatException) {
+ }
+ return null;
+ }
}
Modified: trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/longitudinal/ReportLongitudinalGrapheBuilder.java
===================================================================
--- trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/longitudinal/ReportLongitudinalGrapheBuilder.java 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/longitudinal/ReportLongitudinalGrapheBuilder.java 2013-08-26 14:15:41 UTC (rev 8469)
@@ -20,6 +20,7 @@
import org.fudaa.dodico.crue.metier.emh.ResultatTimeKey;
import org.fudaa.ebli.courbe.EGAxeVertical;
import org.fudaa.ebli.courbe.EGCourbe;
+import org.fudaa.ebli.courbe.EGCourbePersist;
import org.fudaa.ebli.courbe.EGCourbeSimple;
import org.fudaa.ebli.courbe.EGGraphe;
import org.fudaa.ebli.courbe.EGGrapheSimpleModel;
@@ -65,6 +66,12 @@
}
@Override
+ protected Collection<EGCourbePersist> getCachedCourbeConfig(ReportLongitudinalConfig content) {
+ return content.courbeconfigs.values();
+ }
+
+
+ @Override
public List<EGCourbeSimple> getInternCourbes(ReportLongitudinalConfig content, ProgressHandle progress) {
ReportLongitudinalGrapheBuilderCourbe courbeBuilder = new ReportLongitudinalGrapheBuilderCourbe(reportService.getCcm(), this, content);
EGAxeVertical axeZ = courbeBuilder.getAxeZ();
Modified: trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/multivar/ReportMultiVarGrapheBuilder.java
===================================================================
--- trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/multivar/ReportMultiVarGrapheBuilder.java 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/multivar/ReportMultiVarGrapheBuilder.java 2013-08-26 14:15:41 UTC (rev 8469)
@@ -5,6 +5,7 @@
import gnu.trove.TDoubleArrayList;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -44,6 +45,11 @@
}
@Override
+ protected Collection<EGCourbePersist> getCachedCourbeConfig(ReportMultiVarConfig content) {
+ return content.courbeconfigs.values();
+ }
+
+ @Override
public List<EGCourbeSimple> getInternCourbes(ReportMultiVarConfig content, ProgressHandle progress) {
if (!reportService.isRunLoaded()) {
return Collections.emptyList();
Modified: trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/rptg/ReportRPTGGrapheBuilder.java
===================================================================
--- trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/rptg/ReportRPTGGrapheBuilder.java 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/rptg/ReportRPTGGrapheBuilder.java 2013-08-26 14:15:41 UTC (rev 8469)
@@ -5,6 +5,7 @@
import java.awt.Color;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -25,6 +26,7 @@
import org.fudaa.fudaa.crue.loi.common.CourbesUiController;
import org.fudaa.fudaa.crue.loi.loiff.SimpleLoiCourbeModel;
import org.fudaa.fudaa.crue.report.config.AbstractReportGrapheBuilder;
+import org.fudaa.fudaa.crue.report.multivar.ReportMultiVarConfig;
import org.netbeans.api.progress.ProgressHandle;
/**
@@ -38,6 +40,11 @@
}
@Override
+ protected Collection<EGCourbePersist> getCachedCourbeConfig(ReportRPTGConfig content) {
+ return content.courbeconfigs.values();
+ }
+
+ @Override
public void applyLabelsConfigChanged(ReportRPTGConfig content) {
super.applyLabelsConfigChanged(content);
}
Modified: trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/temporal/ReportTemporalGrapheBuilder.java
===================================================================
--- trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/temporal/ReportTemporalGrapheBuilder.java 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/temporal/ReportTemporalGrapheBuilder.java 2013-08-26 14:15:41 UTC (rev 8469)
@@ -6,6 +6,7 @@
import gnu.trove.TDoubleArrayList;
import gnu.trove.TIntObjectHashMap;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -18,6 +19,7 @@
import org.fudaa.dodico.crue.metier.emh.ResultatTimeKey;
import org.fudaa.ebli.courbe.EGAxeHorizontal;
import org.fudaa.ebli.courbe.EGAxeVertical;
+import org.fudaa.ebli.courbe.EGCourbePersist;
import org.fudaa.ebli.courbe.EGCourbeSimple;
import org.fudaa.ebli.courbe.EGModel;
import org.fudaa.fudaa.crue.loi.ViewCourbeManager;
@@ -48,6 +50,11 @@
axeX.setSpecificFormat(new ReportTemporalTimeFormater());
}
+
+ @Override
+ protected Collection<EGCourbePersist> getCachedCourbeConfig(ReportTemporalConfig content) {
+ return content.courbeconfigs.values();
+ }
@Override
public void applyLabelsConfigChanged(ReportTemporalConfig content) {
Modified: trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/transversal/ReportTransversalGrapheBuilder.java
===================================================================
--- trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/transversal/ReportTransversalGrapheBuilder.java 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-report/src/main/java/org/fudaa/fudaa/crue/report/transversal/ReportTransversalGrapheBuilder.java 2013-08-26 14:15:41 UTC (rev 8469)
@@ -4,6 +4,7 @@
package org.fudaa.fudaa.crue.report.transversal;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.StringUtils;
@@ -38,6 +39,7 @@
import org.fudaa.fudaa.crue.report.data.ReportVariableKey;
import org.fudaa.fudaa.crue.report.data.ReportVariableTypeEnum;
import org.fudaa.fudaa.crue.report.helper.ReportProfilHelper;
+import org.fudaa.fudaa.crue.report.temporal.ReportTemporalConfig;
import org.netbeans.api.progress.ProgressHandle;
/**
@@ -52,6 +54,11 @@
super(uiController, loiLabelsManager);
}
+ @Override
+ protected Collection<EGCourbePersist> getCachedCourbeConfig(ReportTransversalConfig content) {
+ return content.courbeconfigs.values();
+ }
+
protected EGAxeVertical getOrCreateAxeVertical() {
return getOrCreateAxeVertical(getVariableZ());
}
Modified: trunk/soft/fudaa-crue/ui-wrapper/pom.xml
===================================================================
--- trunk/soft/fudaa-crue/ui-wrapper/pom.xml 2013-08-23 16:43:43 UTC (rev 8468)
+++ trunk/soft/fudaa-crue/ui-wrapper/pom.xml 2013-08-26 14:15:41 UTC (rev 8469)
@@ -46,6 +46,10 @@
<groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-all</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi-ooxml</artifactId>
+ </dependency>
</dependencies>
<build>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|