jacky6024
7 лет назад
56 изменённых файлов: 1256 добавлений и 388 удалений
@ -0,0 +1,24 @@ |
|||
/******************************************************************************* |
|||
* Copyright 2017 Bstek |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
|||
* use this file except in compliance with the License. You may obtain a copy |
|||
* of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|||
* License for the specific language governing permissions and limitations under |
|||
* the License. |
|||
******************************************************************************/ |
|||
package com.bstek.ureport.chart; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月8日 |
|||
*/ |
|||
public enum FontStyle { |
|||
normal,italic,bold; |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.bstek.ureport.chart.axes; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月14日 |
|||
*/ |
|||
public interface Axes { |
|||
String toJson(); |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.bstek.ureport.chart.axes; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月14日 |
|||
*/ |
|||
public abstract class BaseAxes implements Axes { |
|||
private int rotation; |
|||
private ScaleLabel scaleLabel; |
|||
public int getRotation() { |
|||
return rotation; |
|||
} |
|||
public void setRotation(int rotation) { |
|||
this.rotation = rotation; |
|||
} |
|||
public ScaleLabel getScaleLabel() { |
|||
return scaleLabel; |
|||
} |
|||
public void setScaleLabel(ScaleLabel scaleLabel) { |
|||
this.scaleLabel = scaleLabel; |
|||
} |
|||
} |
@ -0,0 +1,58 @@ |
|||
package com.bstek.ureport.chart.axes; |
|||
|
|||
import com.bstek.ureport.chart.FontStyle; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月14日 |
|||
*/ |
|||
public class ScaleLabel { |
|||
private boolean display=false; |
|||
private String labelString=""; |
|||
private String fontColor="#666"; |
|||
private int fontSize=12; |
|||
private FontStyle fontStyle=FontStyle.normal; |
|||
|
|||
public String toJson(){ |
|||
StringBuilder sb=new StringBuilder(); |
|||
sb.append("{"); |
|||
sb.append("display:"+display+","); |
|||
sb.append("labelString:\""+labelString+"\","); |
|||
sb.append("fontColor:\""+fontColor+"\","); |
|||
sb.append("fontSize:"+fontSize+","); |
|||
sb.append("fontStyle:\""+fontStyle+"\""); |
|||
sb.append("}"); |
|||
return sb.toString(); |
|||
} |
|||
|
|||
public boolean isDisplay() { |
|||
return display; |
|||
} |
|||
public void setDisplay(boolean display) { |
|||
this.display = display; |
|||
} |
|||
public String getLabelString() { |
|||
return labelString; |
|||
} |
|||
public void setLabelString(String labelString) { |
|||
this.labelString = labelString; |
|||
} |
|||
public String getFontColor() { |
|||
return fontColor; |
|||
} |
|||
public void setFontColor(String fontColor) { |
|||
this.fontColor = fontColor; |
|||
} |
|||
public int getFontSize() { |
|||
return fontSize; |
|||
} |
|||
public void setFontSize(int fontSize) { |
|||
this.fontSize = fontSize; |
|||
} |
|||
public FontStyle getFontStyle() { |
|||
return fontStyle; |
|||
} |
|||
public void setFontStyle(FontStyle fontStyle) { |
|||
this.fontStyle = fontStyle; |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.bstek.ureport.chart.axes; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月14日 |
|||
*/ |
|||
public enum XPosition { |
|||
top,bottom; |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.bstek.ureport.chart.axes; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月14日 |
|||
*/ |
|||
public enum YPosition { |
|||
left,right; |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.bstek.ureport.chart.axes.impl; |
|||
|
|||
import com.bstek.ureport.chart.axes.BaseAxes; |
|||
import com.bstek.ureport.chart.axes.ScaleLabel; |
|||
import com.bstek.ureport.chart.axes.XPosition; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月14日 |
|||
*/ |
|||
public class XAxes extends BaseAxes { |
|||
private XPosition xposition=XPosition.bottom; |
|||
@Override |
|||
public String toJson() { |
|||
StringBuilder sb=new StringBuilder(); |
|||
sb.append("{"); |
|||
sb.append("position:\""+xposition+"\","); |
|||
sb.append("minRotation:"+getRotation()+","); |
|||
ScaleLabel scaleLabel=getScaleLabel(); |
|||
if(scaleLabel!=null){ |
|||
sb.append("scaleLabel:"+scaleLabel.toJson()); |
|||
} |
|||
sb.append("}"); |
|||
return sb.toString(); |
|||
} |
|||
public XPosition getXposition() { |
|||
return xposition; |
|||
} |
|||
public void setXposition(XPosition xposition) { |
|||
this.xposition = xposition; |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.bstek.ureport.chart.axes.impl; |
|||
|
|||
import com.bstek.ureport.chart.axes.BaseAxes; |
|||
import com.bstek.ureport.chart.axes.ScaleLabel; |
|||
import com.bstek.ureport.chart.axes.YPosition; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月14日 |
|||
*/ |
|||
public class YAxes extends BaseAxes { |
|||
private YPosition yposition; |
|||
@Override |
|||
public String toJson() { |
|||
StringBuilder sb=new StringBuilder(); |
|||
sb.append("{"); |
|||
sb.append("position:\""+yposition+"\","); |
|||
sb.append("minRotation:"+getRotation()+","); |
|||
ScaleLabel scaleLabel=getScaleLabel(); |
|||
if(scaleLabel!=null){ |
|||
sb.append("scaleLabel:"+scaleLabel.toJson()); |
|||
} |
|||
sb.append("}"); |
|||
return sb.toString(); |
|||
} |
|||
public YPosition getYposition() { |
|||
return yposition; |
|||
} |
|||
public void setYposition(YPosition yposition) { |
|||
this.yposition = yposition; |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.bstek.ureport.chart.dataset; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月13日 |
|||
*/ |
|||
public enum CollectType { |
|||
select,count,sum,avg,max,min; |
|||
} |
@ -1,24 +0,0 @@ |
|||
package com.bstek.ureport.chart.dataset.impl.category; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月9日 |
|||
*/ |
|||
public class CategoryData { |
|||
private String label; |
|||
private List<Double> data; |
|||
public String getLabel() { |
|||
return label; |
|||
} |
|||
public void setLabel(String label) { |
|||
this.label = label; |
|||
} |
|||
public List<Double> getData() { |
|||
return data; |
|||
} |
|||
public void setData(List<Double> data) { |
|||
this.data = data; |
|||
} |
|||
} |
@ -1,9 +0,0 @@ |
|||
package com.bstek.ureport.chart.option; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月8日 |
|||
*/ |
|||
public enum FontStyle { |
|||
normal,italic,bold; |
|||
} |
@ -0,0 +1,154 @@ |
|||
/******************************************************************************* |
|||
* Copyright 2017 Bstek |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
|||
* use this file except in compliance with the License. You may obtain a copy |
|||
* of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|||
* License for the specific language governing permissions and limitations under |
|||
* the License. |
|||
******************************************************************************/ |
|||
package com.bstek.ureport.utils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import com.bstek.ureport.Utils; |
|||
import com.bstek.ureport.build.Context; |
|||
import com.bstek.ureport.definition.value.DatasetValue; |
|||
import com.bstek.ureport.definition.value.ExpressionValue; |
|||
import com.bstek.ureport.definition.value.Value; |
|||
import com.bstek.ureport.exception.ReportComputeException; |
|||
import com.bstek.ureport.expression.model.Expression; |
|||
import com.bstek.ureport.expression.model.expr.BaseExpression; |
|||
import com.bstek.ureport.expression.model.expr.JoinExpression; |
|||
import com.bstek.ureport.expression.model.expr.ParenExpression; |
|||
import com.bstek.ureport.expression.model.expr.dataset.DatasetExpression; |
|||
import com.bstek.ureport.model.Cell; |
|||
|
|||
/** |
|||
* @author Jacky.gao |
|||
* @since 2017年6月12日 |
|||
*/ |
|||
public class DataUtils { |
|||
public static List<?> fetchData(Cell cell, Context context,String datasetName) { |
|||
Cell leftCell=fetchLeftCell(cell, context, datasetName); |
|||
Cell topCell=fetchTopCell(cell, context, datasetName); |
|||
List<Object> leftList=null,topList=null; |
|||
if(leftCell!=null){ |
|||
leftList=leftCell.getBindData(); |
|||
} |
|||
if(topCell!=null){ |
|||
topList=topCell.getBindData(); |
|||
} |
|||
if(leftList==null && topList==null){ |
|||
List<?> data=context.getDatasetData(datasetName); |
|||
return data; |
|||
}else if(leftList==null){ |
|||
return topList; |
|||
}else if(topList==null){ |
|||
return leftList; |
|||
}else{ |
|||
List<Object> list=null; |
|||
Object data=null; |
|||
String prop=null; |
|||
if(leftList.size()>topList.size()){ |
|||
list=topList; |
|||
data=leftCell.getData(); |
|||
Value value=leftCell.getValue(); |
|||
DatasetExpression de=fetchDatasetExpression(value); |
|||
if(de==null){ |
|||
throw new ReportComputeException("Unsupport value : "+value); |
|||
} |
|||
prop=de.getProperty(); |
|||
}else{ |
|||
list=leftList; |
|||
data=topCell.getData(); |
|||
Value value=leftCell.getValue(); |
|||
DatasetExpression de=fetchDatasetExpression(value); |
|||
if(de==null){ |
|||
throw new ReportComputeException("Unsupport value : "+value); |
|||
} |
|||
prop=de.getProperty(); |
|||
} |
|||
List<Object> result=new ArrayList<Object>(); |
|||
for(Object obj:list){ |
|||
Object o=Utils.getProperty(obj, prop); |
|||
if(o==data){ |
|||
result.add(obj); |
|||
} |
|||
} |
|||
return result; |
|||
} |
|||
} |
|||
public static Cell fetchLeftCell(Cell cell, Context context,String datasetName){ |
|||
Cell targetCell=null; |
|||
Cell leftCell=cell.getLeftParentCell(); |
|||
if(leftCell!=null){ |
|||
Value leftCellValue=leftCell.getValue(); |
|||
DatasetExpression leftDSValue=fetchDatasetExpression(leftCellValue); |
|||
if(leftDSValue!=null){ |
|||
String leftDatasetName=leftDSValue.getDatasetName(); |
|||
if(leftDatasetName.equals(datasetName)){ |
|||
if(leftCell.getBindData()!=null){ |
|||
targetCell=leftCell; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return targetCell; |
|||
} |
|||
public static Cell fetchTopCell(Cell cell, Context context,String datasetName){ |
|||
Cell targetCell=null; |
|||
Cell topCell=cell.getTopParentCell(); |
|||
if(topCell!=null){ |
|||
Value topCellValue=topCell.getValue(); |
|||
DatasetExpression leftDSValue=fetchDatasetExpression(topCellValue); |
|||
if(leftDSValue!=null){ |
|||
String leftDatasetName=leftDSValue.getDatasetName(); |
|||
if(leftDatasetName.equals(datasetName)){ |
|||
if(topCell.getBindData()!=null){ |
|||
targetCell=topCell; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return targetCell; |
|||
} |
|||
public static DatasetExpression fetchDatasetExpression(Value value){ |
|||
if(value instanceof ExpressionValue){ |
|||
ExpressionValue exprValue=(ExpressionValue)value; |
|||
Expression expr=exprValue.getExpression(); |
|||
if(expr instanceof DatasetExpression){ |
|||
return (DatasetExpression)expr; |
|||
}else if(expr instanceof ParenExpression){ |
|||
ParenExpression parenExpr=(ParenExpression)expr; |
|||
DatasetExpression targetExpr=buildDatasetExpression(parenExpr); |
|||
return targetExpr; |
|||
}else{ |
|||
return null; |
|||
} |
|||
}else if(value instanceof DatasetValue){ |
|||
return (DatasetValue)value; |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
private static DatasetExpression buildDatasetExpression(JoinExpression joinExpr){ |
|||
List<BaseExpression> expressions=joinExpr.getExpressions(); |
|||
for(BaseExpression baseExpr:expressions){ |
|||
if(baseExpr instanceof DatasetExpression){ |
|||
return (DatasetExpression)baseExpr; |
|||
}else if(baseExpr instanceof JoinExpression){ |
|||
JoinExpression childExpr=(JoinExpression)baseExpr; |
|||
return buildDatasetExpression(childExpr); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
Загрузка…
Ссылка в новой проблеме