blob: 6fd06f9071e2b55fb094ad0e34c1eb94f3c0fe51 [file] [log] [blame]
/**
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*
* This copyright notice shows up in the generated Java code
*/
package org.eclipse.osbp.xtext.chart.jvmmodel;
import com.github.wolfie.refresher.Refresher;
import com.google.common.base.Objects;
import com.vaadin.ui.Component;
import com.vaadin.ui.VerticalLayout;
import elemental.json.JsonException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import org.dussan.vaadin.dcharts.DCharts;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.dsl.semantic.common.types.LAttribute;
import org.eclipse.osbp.dsl.semantic.entity.LEntity;
import org.eclipse.osbp.dsl.semantic.entity.LEntityAttribute;
import org.eclipse.osbp.osgi.hybrid.api.AbstractHybridVaaclipseView;
import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent;
import org.eclipse.osbp.runtime.common.event.IEventDispatcher;
import org.eclipse.osbp.ui.api.datamart.DatamartFilter;
import org.eclipse.osbp.ui.api.datamart.IDatamartFilterGenerator;
import org.eclipse.osbp.ui.api.e4.IE4Focusable;
import org.eclipse.osbp.ui.api.layout.IViewLayoutManager;
import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
import org.eclipse.osbp.ui.api.themes.EnumCssClass;
import org.eclipse.osbp.ui.api.user.IUser;
import org.eclipse.osbp.utils.vaadin.PropertyLookup;
import org.eclipse.osbp.xtext.chart.Chart;
import org.eclipse.osbp.xtext.chart.ChartAxis;
import org.eclipse.osbp.xtext.chart.ChartBar;
import org.eclipse.osbp.xtext.chart.ChartBubble;
import org.eclipse.osbp.xtext.chart.ChartDatamart;
import org.eclipse.osbp.xtext.chart.ChartDonut;
import org.eclipse.osbp.xtext.chart.ChartElement;
import org.eclipse.osbp.xtext.chart.ChartGauge;
import org.eclipse.osbp.xtext.chart.ChartHighlighter;
import org.eclipse.osbp.xtext.chart.ChartInterval;
import org.eclipse.osbp.xtext.chart.ChartLegend;
import org.eclipse.osbp.xtext.chart.ChartLine;
import org.eclipse.osbp.xtext.chart.ChartNumberInterval;
import org.eclipse.osbp.xtext.chart.ChartOption;
import org.eclipse.osbp.xtext.chart.ChartPackage;
import org.eclipse.osbp.xtext.chart.ChartPie;
import org.eclipse.osbp.xtext.chart.ChartRangeElement;
import org.eclipse.osbp.xtext.chart.ChartSegmentColor;
import org.eclipse.osbp.xtext.chart.ChartTree;
import org.eclipse.osbp.xtext.chart.jvmmodel.ChartDSLD3JavaComponentsCreator;
import org.eclipse.osbp.xtext.cubedsl.CubeLevel;
import org.eclipse.osbp.xtext.datamart.common.olap.DerivedCellSet;
import org.eclipse.osbp.xtext.datamartdsl.DatamartAttribute;
import org.eclipse.osbp.xtext.datamartdsl.DatamartCube;
import org.eclipse.osbp.xtext.datamartdsl.DatamartCubeAxis;
import org.eclipse.osbp.xtext.datamartdsl.DatamartCubeElement;
import org.eclipse.osbp.xtext.datamartdsl.DatamartDerivedMeasure;
import org.eclipse.osbp.xtext.datamartdsl.DatamartElement;
import org.eclipse.osbp.xtext.datamartdsl.DatamartEntity;
import org.eclipse.osbp.xtext.datamartdsl.DatamartMeasure;
import org.eclipse.osbp.xtext.datamartdsl.DatamartMember;
import org.eclipse.osbp.xtext.datamartdsl.DatamartNavigation;
import org.eclipse.osbp.xtext.datamartdsl.DatamartOwner;
import org.eclipse.osbp.xtext.datamartdsl.DatamartPackage;
import org.eclipse.osbp.xtext.datamartdsl.DatamartSource;
import org.eclipse.osbp.xtext.datamartdsl.ValueScaleEnum;
import org.eclipse.osbp.xtext.datamartdsl.jvmmodel.DatamartDSLJvmModelInferrer;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.common.types.JvmAnnotationReference;
import org.eclipse.xtext.common.types.JvmConstructor;
import org.eclipse.xtext.common.types.JvmDeclaredType;
import org.eclipse.xtext.common.types.JvmField;
import org.eclipse.xtext.common.types.JvmFormalParameter;
import org.eclipse.xtext.common.types.JvmGenericType;
import org.eclipse.xtext.common.types.JvmMember;
import org.eclipse.xtext.common.types.JvmOperation;
import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.common.types.JvmVisibility;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.xbase.compiler.output.ITreeAppendable;
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer;
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor;
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
/**
* <p>Infers a JVM model from the source model.</p>
*
* <p>The JVM model should contain all elements that would appear in the Java code
* which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
*/
@SuppressWarnings("all")
public class ChartDSLJvmModelInferrer extends AbstractModelInferrer {
@Inject
@Extension
private JvmTypesBuilder _jvmTypesBuilder;
@Inject
@Extension
private IQualifiedNameProvider _iQualifiedNameProvider;
@Inject
@Extension
private DatamartDSLJvmModelInferrer datamartInferrer;
@Inject
@Extension
private ChartDSLD3JavaComponentsCreator _chartDSLD3JavaComponentsCreator;
/**
* <p>infer method dispatches the necessary routines to build fields, setter, getter, constructors and methods of the generated code.</p>
*/
protected void _infer(final ChartPackage pckg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
EList<Chart> _charts = pckg.getCharts();
for (final Chart chart : _charts) {
{
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(pckg);
String _plus = (_fullyQualifiedName + ".");
String _name = chart.getName();
String _plus_1 = (_plus + _name);
String _plus_2 = (_plus_1 + "Chart");
JvmGenericType cls = this._jvmTypesBuilder.toClass(chart, _plus_2);
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(AbstractHybridVaaclipseView.class));
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IUser.UserLocaleListener.class));
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IDatamartFilterGenerator.FilterChangeListener.class));
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IEventDispatcher.Receiver.class));
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IE4Focusable.class));
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(pckg));
this.toFields(it, chart);
this.toConstructor(it, chart);
this.toGetterSetter(it, chart);
this.toOperations(it, chart);
};
acceptor.<JvmGenericType>accept(cls, _function);
ChartOption _charttype = chart.getCharttype();
if ((_charttype instanceof ChartTree)) {
this._chartDSLD3JavaComponentsCreator.createJsJavaComponent(chart, acceptor);
}
}
}
}
/**
* <p>build the constructors to be used by an e4 application.</p>
*/
public void toConstructor(final JvmDeclaredType type, final Chart chart) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmConstructor> _function = (JvmConstructor it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(chart, "parent", this._typeReferenceBuilder.typeRef(VerticalLayout.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(chart, "context", this._typeReferenceBuilder.typeRef(IEclipseContext.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
EList<JvmFormalParameter> _parameters_2 = it.getParameters();
JvmFormalParameter _parameter_2 = this._jvmTypesBuilder.toParameter(chart, "app", this._typeReferenceBuilder.typeRef(MApplication.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super(parent,context,app);");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(chart, _function);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor);
}
/**
* <p>build the class variables.</p>
*/
public void toFields(final JvmDeclaredType type, final Chart chart) {
JvmField field = null;
final Procedure1<JvmField> _function = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("org.slf4j.LoggerFactory.getLogger(\"charts\")");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_1);
};
field = this._jvmTypesBuilder.toField(chart, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function);
field.setStatic(true);
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
final Procedure1<JvmField> _function_1 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(chart, "user", this._typeReferenceBuilder.typeRef(IUser.class), _function_1);
EList<JvmMember> _members_1 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field);
final Procedure1<JvmField> _function_2 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(chart, "eclipseContext", this._typeReferenceBuilder.typeRef(IEclipseContext.class), _function_2);
EList<JvmMember> _members_2 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field);
field = this._jvmTypesBuilder.toField(chart, "coordinateSystem", this._typeReferenceBuilder.typeRef(ArrayList.class, this._typeReferenceBuilder.typeRef(Integer.class)));
EList<JvmMember> _members_3 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_3, field);
field = this._jvmTypesBuilder.toField(chart, "filterGenerator", this._typeReferenceBuilder.typeRef(IDatamartFilterGenerator.class));
EList<JvmMember> _members_4 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_4, field);
field = this._jvmTypesBuilder.toField(chart, "layoutManager", this._typeReferenceBuilder.typeRef(IViewLayoutManager.class));
EList<JvmMember> _members_5 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_5, field);
String _sourceDataMartRefName = this.getSourceDataMartRefName(chart);
boolean _tripleNotEquals = (_sourceDataMartRefName != null);
if (_tripleNotEquals) {
EObject _eContainer = chart.getSource().getDatamartRef().eContainer();
String packageName = this._iQualifiedNameProvider.getFullyQualifiedName(((DatamartPackage) _eContainer)).toString();
StringConcatenation _builder = new StringConcatenation();
_builder.append(packageName);
_builder.append(".");
String _string = chart.getSource().getDatamartRef().getName().toString();
_builder.append(_string);
_builder.append("Datamart");
field = this._jvmTypesBuilder.toField(chart, "datamartInstance", this._typeReferenceBuilder.typeRef(_builder.toString()));
EList<JvmMember> _members_6 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_6, field);
}
field = this._jvmTypesBuilder.toField(chart, "chartRefresher", this._typeReferenceBuilder.typeRef(Refresher.class));
EList<JvmMember> _members_7 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_7, field);
field = this._jvmTypesBuilder.toField(chart, "chartRefresherDone", this._typeReferenceBuilder.typeRef(boolean.class));
EList<JvmMember> _members_8 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_8, field);
field = this._jvmTypesBuilder.toField(chart, "chartRenderDelay", this._typeReferenceBuilder.typeRef(Refresher.class));
EList<JvmMember> _members_9 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_9, field);
field = this._jvmTypesBuilder.toField(chart, "dataComponent", this._typeReferenceBuilder.typeRef(Component.class));
EList<JvmMember> _members_10 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_10, field);
field = this._jvmTypesBuilder.toField(chart, "attributeLookupMap", this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(String.class), this._typeReferenceBuilder.typeRef(PropertyLookup.class)));
EList<JvmMember> _members_11 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_11, field);
field = this._jvmTypesBuilder.toField(chart, "charts", this._typeReferenceBuilder.typeRef(ArrayList.class, this._typeReferenceBuilder.typeRef(DCharts.class)));
EList<JvmMember> _members_12 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_12, field);
final Procedure1<JvmField> _function_3 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(chart, "eventBroker", this._typeReferenceBuilder.typeRef(IEventBroker.class), _function_3);
EList<JvmMember> _members_13 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_13, field);
field = this._jvmTypesBuilder.toField(chart, "refreshView", this._typeReferenceBuilder.typeRef(EventHandler.class));
EList<JvmMember> _members_14 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_14, field);
final Procedure1<JvmField> _function_4 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(chart, "dslMetadataService", this._typeReferenceBuilder.typeRef(IDSLMetadataService.class), _function_4);
EList<JvmMember> _members_15 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_15, field);
final Procedure1<JvmField> _function_5 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(chart, "eventDispatcher", this._typeReferenceBuilder.typeRef(IEventDispatcher.class), _function_5);
EList<JvmMember> _members_16 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_16, field);
}
/**
* <p>build the getters and setters from class variables.</p>
*/
public void toGetterSetter(final JvmDeclaredType type, final Chart chart) {
JvmOperation operation = null;
operation = this._jvmTypesBuilder.toGetter(chart, "coordinateSystem", this._typeReferenceBuilder.typeRef(ArrayList.class, this._typeReferenceBuilder.typeRef(Integer.class)));
operation.setVisibility(JvmVisibility.PUBLIC);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, operation);
}
/**
* <p>build the methods.</p>
*/
public void toOperations(final JvmDeclaredType type, final Chart chart) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(PostConstruct.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("user.addUserLocaleListener(this);");
_builder.newLine();
_builder.append("filterGenerator.addFilterChangeListener(this);");
_builder.newLine();
_builder.append("eventDispatcher.addEventReceiver(this);");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(chart, "activate", this._typeReferenceBuilder.typeRef(Void.TYPE), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
EList<JvmMember> _members_1 = type.getMembers();
final Procedure1<JvmOperation> _function_1 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(PreDestroy.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("user.removeUserLocaleListener(this);");
_builder.newLine();
_builder.append("filterGenerator.removeFilterChangeListener(this);");
_builder.newLine();
_builder.append("eventDispatcher.removeEventReceiver(this);");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_2);
};
JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(chart, "deactivate", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1);
EList<JvmMember> _members_2 = type.getMembers();
final Procedure1<JvmOperation> _function_2 = (JvmOperation it) -> {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(chart, "parent", this._typeReferenceBuilder.typeRef(VerticalLayout.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _createView = this.createView(chart);
_builder.append(_createView);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_3);
};
JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(chart, "createView", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_2);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2);
EList<JvmMember> _members_3 = type.getMembers();
final Procedure1<JvmOperation> _function_3 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _createComponents = this.createComponents(chart);
_builder.append(_createComponents);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_4);
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(chart, "createComponents", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3);
EList<JvmMember> _members_4 = type.getMembers();
final Procedure1<JvmOperation> _function_4 = (JvmOperation it) -> {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(chart, "cellSet", this._typeReferenceBuilder.typeRef(DerivedCellSet.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(chart, "axisNo", this._typeReferenceBuilder.typeRef(Integer.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _createTabSheet = this.createTabSheet(chart);
_builder.append(_createTabSheet);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_5);
};
JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(chart, "createTabSheet", this._typeReferenceBuilder.typeRef(Component.class), _function_4);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4);
ChartOption _charttype = chart.getCharttype();
boolean _not = (!(_charttype instanceof ChartTree));
if (_not) {
EList<JvmMember> _members_5 = type.getMembers();
final Procedure1<JvmOperation> _function_5 = (JvmOperation it) -> {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(chart, "cellSet", this._typeReferenceBuilder.typeRef(DerivedCellSet.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _createChart = this.createChart(chart);
_builder.append(_createChart);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_6);
};
JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(chart, "createChart", this._typeReferenceBuilder.typeRef(Component.class), _function_5);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5);
}
ChartOption _charttype_1 = chart.getCharttype();
if ((_charttype_1 instanceof ChartTree)) {
EList<JvmMember> _members_6 = type.getMembers();
final Procedure1<JvmOperation> _function_6 = (JvmOperation it) -> {
EList<JvmTypeReference> _exceptions = it.getExceptions();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(JsonException.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(chart, "cxCellSet", this._typeReferenceBuilder.typeRef(DerivedCellSet.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_7 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
CharSequence _createD3Chart = this._chartDSLD3JavaComponentsCreator.createD3Chart(chart);
_builder.append(_createD3Chart);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_7);
};
JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(chart, "createD3Chart", this._typeReferenceBuilder.typeRef(Component.class), _function_6);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6);
}
EList<JvmMember> _members_7 = type.getMembers();
final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Focus.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Component parent = getParent();");
_builder.newLine();
_builder.append("while(!(parent instanceof Panel) && parent != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("parent = parent.getParent();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("if(parent != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("((Panel)parent).focus();");
_builder.newLine();
_builder.append("}");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_8);
};
JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(chart, "setFocus", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_7);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
EList<JvmMember> _members_8 = type.getMembers();
final Procedure1<JvmOperation> _function_8 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(chart, "locale", this._typeReferenceBuilder.typeRef(Locale.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
CharSequence _localeChanged = this.localeChanged(chart);
_builder.append(_localeChanged);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_9);
};
JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(chart, "localeChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_8);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8);
EList<JvmMember> _members_9 = type.getMembers();
final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(chart, "changedFilter", this._typeReferenceBuilder.typeRef(DatamartFilter.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("renderData();");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_10);
};
JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(chart, "filterChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_9);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
EList<JvmMember> _members_10 = type.getMembers();
final Procedure1<JvmOperation> _function_10 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(chart, "event", this._typeReferenceBuilder.typeRef(EventDispatcherEvent.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _receiveEvent = this.receiveEvent(chart);
_builder.append(_receiveEvent);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_11);
};
JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(chart, "receiveEvent", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_10);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10);
}
public String getSourceDataMartRefName(final Chart chart) {
if ((((chart.getSource() != null) && (chart.getSource().getDatamartRef() != null)) && (chart.getSource().getDatamartRef().getName() != null))) {
return chart.getSource().getDatamartRef().getName().toString();
} else {
return null;
}
}
/**
* <p>build the main method to be called from e4.</p>
*/
public String createView(final Chart chart) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("eclipseContext.set(IE4Focusable.class, this);");
_builder.newLine();
_builder.append("chartRefresherDone = false;");
_builder.newLine();
_builder.append("charts = new ArrayList<DCharts>();");
_builder.newLine();
_builder.append("coordinateSystem = new ArrayList<Integer>();");
_builder.newLine();
_builder.append("parent.setPrimaryStyleName(\"osbp\"); // <== is THIS necessary any more???");
_builder.newLine();
_builder.append("parent.addStyleName(\"");
String _styleName = EnumCssClass.VIEW.styleName();
_builder.append(_styleName);
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("parent.addStyleName(\"");
String _styleName_1 = EnumCssClass.CHART_VIEW.styleName();
_builder.append(_styleName_1);
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("parent.setSizeFull();");
_builder.newLine();
_builder.append("layoutManager = new ViewLayoutManager();");
_builder.newLine();
_builder.append("layoutManager.init(parent);");
_builder.newLine();
_builder.append("datamartInstance = new ");
String _sourceDataMartRefName = this.getSourceDataMartRefName(chart);
_builder.append(_sourceDataMartRefName);
_builder.append("Datamart();");
_builder.newLineIfNotEmpty();
_builder.append("datamartInstance.setUser(user);");
_builder.newLine();
_builder.append("filterGenerator = new DatamartFilterGenerator(datamartInstance, dslMetadataService);");
_builder.newLine();
_builder.append("filterGenerator.createUIFilters(layoutManager);");
_builder.newLine();
_builder.append("chartRefresher = new Refresher();");
_builder.newLine();
_builder.append("chartRenderDelay = new Refresher();");
_builder.newLine();
_builder.append("attributeLookupMap = new HashMap<String,PropertyLookup>();");
_builder.newLine();
String body = _builder.toString();
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.newLineIfNotEmpty();
_builder_1.append("refreshView = ");
String _refreshView = this.refreshView(chart);
_builder_1.append(_refreshView);
_builder_1.newLineIfNotEmpty();
body = _builder_1.toString();
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body);
_builder_2.newLineIfNotEmpty();
_builder_2.append("chartRenderDelay.setRefreshInterval(100);");
_builder_2.newLine();
_builder_2.append("chartRenderDelay.addListener(new com.github.wolfie.refresher.Refresher.RefreshListener() {");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("@Override");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("public void refresh(final Refresher source) {");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("// refresh only once");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("layoutManager.removeExtension(source);");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("log.debug(\"initial - show delayed\");");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("for(DCharts chart : charts) {");
_builder_2.newLine();
_builder_2.append("\t\t\t");
_builder_2.append("chart.show();");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("chartRefresherDone = true;");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("});");
_builder_2.newLine();
_builder_2.append("layoutManager.addExtension(chartRenderDelay);");
_builder_2.newLine();
body = _builder_2.toString();
boolean _isPolling = chart.isPolling();
if (_isPolling) {
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body);
_builder_3.newLineIfNotEmpty();
_builder_3.append("chartRefresher.setRefreshInterval(");
int _pollingTime = chart.getPollingTime();
_builder_3.append(_pollingTime);
_builder_3.append("*1000);");
_builder_3.newLineIfNotEmpty();
_builder_3.append("chartRefresher.addListener(new com.github.wolfie.refresher.Refresher.RefreshListener() {");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("@Override");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("public void refresh(final Refresher source) {");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("renderData();");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("});");
_builder_3.newLine();
_builder_3.append("layoutManager.addExtension(chartRefresher);");
_builder_3.newLine();
body = _builder_3.toString();
}
StringConcatenation _builder_4 = new StringConcatenation();
_builder_4.append(body);
_builder_4.append("// to resize the chart according to browser");
_builder_4.newLineIfNotEmpty();
_builder_4.append("Page.getCurrent().addBrowserWindowResizeListener(new BrowserWindowResizeListener() {");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("@Override");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("public void browserWindowResized(BrowserWindowResizeEvent event) {");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("log.debug(\"browserWindowResized - mark dirty\");");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("getParent().markAsDirtyRecursive();");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("});");
_builder_4.newLine();
_builder_4.append("// to resize the chart according to split positions of partsashcontainer - setContainerData is tracked");
_builder_4.newLine();
_builder_4.append("EObject container = ((EObject)eclipseContext.get(MUIElement.class)).eContainer();");
_builder_4.newLine();
_builder_4.append("if(!(container instanceof MPartStack)) {");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("container = (EObject)eclipseContext.get(MUIElement.class);");
_builder_4.newLine();
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("container.eAdapters().add(new AdapterImpl() {");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("public void notifyChanged(Notification notification) {");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("if (notification.getEventType()==Notification.SET && ");
_builder_4.newLine();
_builder_4.append("\t\t\t\t");
_builder_4.append("notification.getFeatureID(UIElementImpl.class) == UiPackageImpl.UI_ELEMENT__CONTAINER_DATA)");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("{");
_builder_4.newLine();
_builder_4.append("\t\t\t");
_builder_4.append("log.debug(\"split position changed - mark dirty\");");
_builder_4.newLine();
_builder_4.append("\t\t\t");
_builder_4.append("getParent().markAsDirtyRecursive();");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("});");
_builder_4.newLine();
body = _builder_4.toString();
return body;
}
/**
* <p>create a handler for external triggered refresh requests.</p>
*/
public String refreshView(final Chart chart) {
String body = "";
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
_builder.newLineIfNotEmpty();
_builder.append("new EventHandler() {");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void handleEvent(Event event) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("renderData();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("};");
_builder.newLine();
body = _builder.toString();
return body;
}
/**
* <p>build the data components.</p>
*/
public String createComponents(final Chart chart) {
String body = "";
ChartDatamart _source = chart.getSource();
boolean _tripleNotEquals = (_source != null);
if (_tripleNotEquals) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
_builder.append("// get the results");
_builder.newLineIfNotEmpty();
_builder.append("final DerivedCellSet cellSet = datamartInstance.getResults(getTaskOperativeDtoClass(), getTaskInitialOperativeDtos());");
_builder.newLine();
_builder.append("getCoordinateSystem().clear();");
_builder.newLine();
_builder.append("if (cellSet == null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("promptSecurityMessage(dslMetadataService.translate(user.getLocale().toLanguageTag(), \"securityMessage\"), layoutManager.getDataArea());");
_builder.newLine();
_builder.append("\t");
_builder.append("return;");
_builder.newLine();
_builder.append("} else {");
_builder.newLine();
_builder.append("\t");
_builder.append("layoutManager.getDataArea().removeAllComponents();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("// generate a new result component");
_builder.newLine();
_builder.append("if (cellSet != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("// create a multidimensional coordinate system against the cellSet");
_builder.newLine();
_builder.append("\t");
_builder.append("for\t(int axis = 0; axis < cellSet.getAxes().size(); axis++) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("getCoordinateSystem().add(0);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("// remove any previous component");
_builder.newLine();
_builder.append("\t");
_builder.append("if\t(dataComponent != null) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("layoutManager.getDataArea().removeComponent(dataComponent);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("dataComponent = null;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("if (cellSet.getAxes().size() < 2) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("log.error(\"at least 2 axes from referenced datamart ");
String _name = chart.getSource().getDatamartRef().getName();
_builder.append(_name, "\t\t");
_builder.append(" are needed to render ");
String _name_1 = chart.getName();
_builder.append(_name_1, "\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("} else {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("dataComponent = createTabSheet(cellSet, cellSet.getAxes().size());");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(dataComponent != null) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("dataComponent.setSizeFull();");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("dataComponent.setId(\"dataComponent\");");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("dataComponent.addStyleName(\"");
String _styleName = EnumCssClass.DATA_COMPONENT.styleName();
_builder.append(_styleName, "\t\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("layoutManager.getDataArea().addComponent(dataComponent);");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("layoutManager.getDataArea().setExpandRatio(dataComponent, 1);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("else {");
_builder.newLine();
_builder.append("\t");
_builder.append("log.error(\"referenced datamart ");
String _name_2 = chart.getSource().getDatamartRef().getName();
_builder.append(_name_2, "\t");
_builder.append(" generates no results\");");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
body = _builder.toString();
} else {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.newLineIfNotEmpty();
_builder_1.append("// generate a new result component");
_builder_1.newLine();
_builder_1.append("try {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("// remove any previous component");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("if\t(dataComponent != null) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("layoutManager.getDataArea().removeComponent(dataComponent);");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("dataComponent = null;");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}\t\t\t\t");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("dataComponent = createTabSheet(null, 2);");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("dataComponent.setSizeFull();");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("dataComponent.setId(\"dataComponent\");");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("dataComponent.addStyleName(\"");
String _styleName_1 = EnumCssClass.DATA_COMPONENT.styleName();
_builder_1.append(_styleName_1, "\t");
_builder_1.append("\");");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("layoutManager.getDataArea().addComponent(dataComponent);");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("layoutManager.getDataArea().setExpandRatio(dataComponent, 1);");
_builder_1.newLine();
_builder_1.append("} catch (DerivedOlapException e) {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("log.error(e.getLocalizedMessage());");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
body = _builder_1.toString();
}
return body;
}
/**
* <p>if more than 2 axes (dimensions) are found in the cellSet, build recursive tabsheets as long as the remaining axes are more than 2.</p>
*/
public String createTabSheet(final Chart chart) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("charts.clear();");
_builder.newLine();
_builder.append("// either create a recursive tabsheet or a chart");
_builder.newLine();
_builder.append("Component component = null;");
_builder.newLine();
_builder.append("if\t(axisNo == 2) {");
_builder.newLine();
String body = _builder.toString();
ChartOption _charttype = chart.getCharttype();
if ((_charttype instanceof ChartTree)) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("try {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("component = createD3Chart(cellSet);");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("} catch (JsonException e) {");
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("log.error(e.getLocalizedMessage());");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
body = _builder_1.toString();
} else {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body);
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t");
_builder_2.append("component = createChart(cellSet);");
_builder_2.newLine();
body = _builder_2.toString();
}
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body);
_builder_3.newLineIfNotEmpty();
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("else {\t\t");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("Integer axis = axisNo-1;");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("TabSheet tabsheet = new TabSheet();");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("tabsheet.setSizeFull();");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("DerivedAxis tabAxis = cellSet.getAxes().get(axis);");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("// create a tab page for all tab axis members");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("int tabNo = 0;");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("for\t(DerivedPosition column : tabAxis.getPositions()) {");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("// create the title for the axis");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("String title = null;");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("for (DerivedMember member : column.getMembers()) {");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("if\t(title == null) {");
_builder_3.newLine();
_builder_3.append("\t\t\t\t");
_builder_3.append("title = dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getCaption());");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("else {");
_builder_3.newLine();
_builder_3.append("\t\t\t\t");
_builder_3.append("title += \" / \"+dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getCaption());");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("// position the data to this coordinate");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("getCoordinateSystem().set(axis, tabNo);");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("component = createTabSheet(cellSet, axis);");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("// set the caption");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("if (component != null) {");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("component.setCaption(title);");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("// add the component as a tab page");
_builder_3.newLine();
_builder_3.append("\t\t\t");
_builder_3.append("tabsheet.addComponent(component);");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t\t");
_builder_3.append("tabNo++;");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("\t");
_builder_3.append("component = tabsheet;");
_builder_3.newLine();
_builder_3.append("}");
_builder_3.newLine();
_builder_3.append("return component;");
body = _builder_3.toString();
return body;
}
/**
* <p>build the chart components.</p>
*/
public String createChart(final Chart chart) {
String body = "";
String postfix = "";
String chartType = "";
boolean hasAxis = true;
HashMap<String, String> multipleAxes = CollectionLiterals.<String, String>newHashMap();
ChartAxis category_axis = null;
ChartAxis data_axis = null;
ChartAxis inner_axis = null;
ChartAxis outer_axis = null;
boolean axisSwitch = false;
String axisPrefix = "XY";
ChartOption _charttype = chart.getCharttype();
if ((_charttype instanceof ChartBar)) {
ChartOption _charttype_1 = chart.getCharttype();
boolean _isSwapped = ((ChartBar) _charttype_1).isSwapped();
if (_isSwapped) {
axisPrefix = "YX";
axisSwitch = true;
}
}
EList<ChartElement> _elements = chart.getSource().getElements();
for (final ChartElement element : _elements) {
if ((element instanceof ChartAxis)) {
ChartAxis axis = ((ChartAxis) element);
if ((axis.getAxis().getName().getName().equals("COLUMNS") || axis.getAxis().getName().getName().equals("ROWS"))) {
if (((axis.getRenderType().getName().equals("LOG") || axis.getRenderType().getName().equals("LINEAR")) || axis.getRenderType().getName().equals("PYRAMID"))) {
data_axis = axis;
}
if ((axis.getRenderType().getName().equals("CATEGORY") || axis.getRenderType().getName().equals("DATE"))) {
category_axis = axis;
}
}
}
}
ChartOption _charttype_2 = chart.getCharttype();
if ((_charttype_2 instanceof ChartBar)) {
chartType = "BAR";
StringConcatenation _builder = new StringConcatenation();
_builder.append("_");
_builder.append(chartType);
postfix = _builder.toString();
inner_axis = category_axis;
outer_axis = data_axis;
} else {
ChartOption _charttype_3 = chart.getCharttype();
if ((_charttype_3 instanceof ChartBubble)) {
chartType = "BUBBLE";
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("_");
_builder_1.append(chartType);
postfix = _builder_1.toString();
hasAxis = true;
inner_axis = data_axis;
outer_axis = category_axis;
} else {
ChartOption _charttype_4 = chart.getCharttype();
if ((_charttype_4 instanceof ChartDonut)) {
chartType = "DONUT";
hasAxis = false;
inner_axis = category_axis;
outer_axis = data_axis;
} else {
ChartOption _charttype_5 = chart.getCharttype();
if ((_charttype_5 instanceof ChartLine)) {
chartType = "LINE";
inner_axis = category_axis;
outer_axis = data_axis;
} else {
ChartOption _charttype_6 = chart.getCharttype();
if ((_charttype_6 instanceof ChartPie)) {
chartType = "PIE";
hasAxis = false;
inner_axis = data_axis;
outer_axis = category_axis;
} else {
ChartOption _charttype_7 = chart.getCharttype();
if ((_charttype_7 instanceof ChartGauge)) {
chartType = "METER_GAUGE";
hasAxis = false;
inner_axis = data_axis;
outer_axis = category_axis;
}
}
}
}
}
}
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("List<Integer> coordinate = new ArrayList<Integer>(getCoordinateSystem());");
_builder_2.newLine();
body = _builder_2.toString();
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body);
_builder_3.append("// create a label series");
_builder_3.newLineIfNotEmpty();
_builder_3.append("List<String> ");
String _literal = data_axis.getAxis().getName().getLiteral();
_builder_3.append(_literal);
_builder_3.append("TitlesArray = new ArrayList<String>();");
_builder_3.newLineIfNotEmpty();
_builder_3.append("for\t(DerivedPosition pos : cellSet.getAxes().get(");
int _value = data_axis.getAxis().getName().getValue();
_builder_3.append(_value);
_builder_3.append(").getPositions()) {");
_builder_3.newLineIfNotEmpty();
body = _builder_3.toString();
StringConcatenation _builder_4 = new StringConcatenation();
_builder_4.append(body);
_builder_4.newLineIfNotEmpty();
_builder_4.append("\t");
_builder_4.append("String title = null;");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("for (DerivedMember member : pos.getMembers()) {");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("if(member.getType() == MemberType.MEASURE) {");
_builder_4.newLine();
_builder_4.append("\t\t\t");
_builder_4.append("if\t(title == null) {");
_builder_4.newLine();
_builder_4.append("\t\t\t\t");
_builder_4.append("title = dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getCaption());");
_builder_4.newLine();
_builder_4.append("\t\t\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t\t\t");
_builder_4.append("else {");
_builder_4.newLine();
_builder_4.append("\t\t\t\t");
_builder_4.append("title += \" \"+dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getCaption());");
_builder_4.newLine();
_builder_4.append("\t\t\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("if(title != null) {");
_builder_4.newLine();
_builder_4.append("\t\t");
String _literal_1 = data_axis.getAxis().getName().getLiteral();
_builder_4.append(_literal_1, "\t\t");
_builder_4.append("TitlesArray.add(title);");
_builder_4.newLineIfNotEmpty();
_builder_4.append("\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("}");
_builder_4.newLine();
body = _builder_4.toString();
if (hasAxis) {
StringConcatenation _builder_5 = new StringConcatenation();
_builder_5.append(body);
_builder_5.append("Series ");
String _literal_2 = data_axis.getAxis().getName().getLiteral();
_builder_5.append(_literal_2);
_builder_5.append("Series = new Series();");
_builder_5.newLineIfNotEmpty();
body = _builder_5.toString();
StringConcatenation _builder_6 = new StringConcatenation();
_builder_6.append(body);
_builder_6.append("if (");
String _literal_3 = data_axis.getAxis().getName().getLiteral();
_builder_6.append(_literal_3);
_builder_6.append("TitlesArray.size() > 0) {");
_builder_6.newLineIfNotEmpty();
body = _builder_6.toString();
boolean showMarker = false;
ChartOption _charttype_8 = chart.getCharttype();
if ((_charttype_8 instanceof ChartLine)) {
ChartOption _charttype_9 = chart.getCharttype();
showMarker = ((ChartLine) _charttype_9).isShowMarker();
}
StringConcatenation _builder_7 = new StringConcatenation();
_builder_7.append(body);
String _createLabelSeries = this.createLabelSeries(chart, data_axis, multipleAxes, axisPrefix, showMarker);
_builder_7.append(_createLabelSeries);
body = _builder_7.toString();
StringConcatenation _builder_8 = new StringConcatenation();
_builder_8.append(body);
_builder_8.append("}");
_builder_8.newLineIfNotEmpty();
body = _builder_8.toString();
}
StringConcatenation _builder_9 = new StringConcatenation();
_builder_9.append(body);
_builder_9.append("// create the data series ticks");
_builder_9.newLineIfNotEmpty();
_builder_9.append("String ");
String _literal_4 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_4);
_builder_9.append("AxisLabel = \"\";");
_builder_9.newLineIfNotEmpty();
_builder_9.append("Boolean ");
String _literal_5 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_5);
_builder_9.append("AxisLabelSet = false;");
_builder_9.newLineIfNotEmpty();
_builder_9.append("List<String> ");
String _literal_6 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_6);
_builder_9.append("TitlesArray = new ArrayList<String>();");
_builder_9.newLineIfNotEmpty();
_builder_9.append("for\t(DerivedPosition pos : cellSet.getAxes().get(");
int _value_1 = category_axis.getAxis().getName().getValue();
_builder_9.append(_value_1);
_builder_9.append(").getPositions()) {");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t");
_builder_9.append("String title = \"\";");
_builder_9.newLine();
_builder_9.append("\t");
_builder_9.append("for (DerivedMember member : pos.getMembers()) {");
_builder_9.newLine();
_builder_9.append("\t\t");
_builder_9.append("if(member.getType() == MemberType.REGULAR) {");
_builder_9.newLine();
_builder_9.append("\t \t");
_builder_9.append("String[] tokens = member.getUniqueName().split(\"\\\\]\\\\.\\\\[\");");
_builder_9.newLine();
_builder_9.append("\t \t");
_builder_9.append("if (!");
String _literal_7 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_7, "\t \t");
_builder_9.append("AxisLabelSet) {");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t \t\t");
_builder_9.append("if (");
String _literal_8 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_8, "\t \t\t");
_builder_9.append("AxisLabel.length() > 0) {");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t \t\t\t");
String _literal_9 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_9, "\t \t\t\t");
_builder_9.append("AxisLabel += \" / \";");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t \t\t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("\t \t\t");
String _literal_10 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_10, "\t \t\t");
_builder_9.append("AxisLabel += dslMetadataService.translate(user.getLocale().toLanguageTag(), member.getLevel().getName());");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t \t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("\t \t");
_builder_9.append("int start = 1;");
_builder_9.newLine();
_builder_9.append("\t \t");
_builder_9.append("// if shortlabel is configured, use only last level name");
_builder_9.newLine();
_builder_9.append("\t \t");
_builder_9.append("if (");
boolean _booleanValue = Boolean.valueOf(category_axis.isShortLabel()).booleanValue();
_builder_9.append(_booleanValue, "\t \t");
_builder_9.append(") {");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t \t\t");
_builder_9.append("start = tokens.length-1;");
_builder_9.newLine();
_builder_9.append("\t \t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("\t \t");
_builder_9.append("for\t(int token = start; token < tokens.length; token++) {");
_builder_9.newLine();
_builder_9.append("\t \t\t");
_builder_9.append("title += dslMetadataService.translate(user.getLocale().toLanguageTag(), tokens[token])+\" \";");
_builder_9.newLine();
_builder_9.append("\t \t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("\t ");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("\t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("\t");
_builder_9.append("if(title != null) {");
_builder_9.newLine();
_builder_9.append("\t\t");
String _literal_11 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_11, "\t\t");
_builder_9.append("AxisLabelSet = true;");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t\t");
String _literal_12 = category_axis.getAxis().getName().getLiteral();
_builder_9.append(_literal_12, "\t\t");
_builder_9.append("TitlesArray.add(title.trim().replace(\"[\", \"\").replace(\"]\", \"\"));");
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t");
_builder_9.append("}");
_builder_9.newLine();
_builder_9.append("}");
_builder_9.newLine();
body = _builder_9.toString();
if (hasAxis) {
StringConcatenation _builder_10 = new StringConcatenation();
_builder_10.append(body);
_builder_10.append("Ticks ");
String _literal_13 = category_axis.getAxis().getName().getLiteral();
_builder_10.append(_literal_13);
_builder_10.append("Ticks = new Ticks();");
_builder_10.newLineIfNotEmpty();
String _literal_14 = category_axis.getAxis().getName().getLiteral();
_builder_10.append(_literal_14);
_builder_10.append("Ticks.add(");
String _literal_15 = category_axis.getAxis().getName().getLiteral();
_builder_10.append(_literal_15);
_builder_10.append("TitlesArray.toArray());");
_builder_10.newLineIfNotEmpty();
body = _builder_10.toString();
}
StringConcatenation _builder_11 = new StringConcatenation();
_builder_11.append(body);
_builder_11.newLineIfNotEmpty();
_builder_11.append("if(");
String _literal_16 = category_axis.getAxis().getName().getLiteral();
_builder_11.append(_literal_16);
_builder_11.append("TitlesArray.isEmpty()) {");
_builder_11.newLineIfNotEmpty();
_builder_11.append("\t");
_builder_11.append("return null;");
_builder_11.newLine();
_builder_11.append("}");
_builder_11.newLine();
_builder_11.append("// copy cellset data to data series");
_builder_11.newLine();
_builder_11.append("DataSeries dataSeries = new DataSeries();");
_builder_11.newLine();
body = _builder_11.toString();
ChartOption _charttype_10 = chart.getCharttype();
if ((_charttype_10 instanceof ChartBubble)) {
StringConcatenation _builder_12 = new StringConcatenation();
_builder_12.append(body);
_builder_12.append("dataSeries.newSeries();");
_builder_12.newLineIfNotEmpty();
body = _builder_12.toString();
}
StringConcatenation _builder_13 = new StringConcatenation();
_builder_13.append(body);
_builder_13.append("int ");
String _literal_17 = outer_axis.getAxis().getName().getLiteral();
_builder_13.append(_literal_17);
_builder_13.append("No = 0;");
_builder_13.newLineIfNotEmpty();
body = _builder_13.toString();
StringConcatenation _builder_14 = new StringConcatenation();
_builder_14.append(body);
_builder_14.append("for\t(DerivedPosition ");
String _literal_18 = outer_axis.getAxis().getName().getLiteral();
_builder_14.append(_literal_18);
_builder_14.append("Pos : cellSet.getAxes().get(");
int _value_2 = outer_axis.getAxis().getName().getValue();
_builder_14.append(_value_2);
_builder_14.append(").getPositions()) {");
_builder_14.newLineIfNotEmpty();
body = _builder_14.toString();
StringConcatenation _builder_15 = new StringConcatenation();
_builder_15.append(body);
_builder_15.append("\tcoordinate.set(");
int _value_3 = outer_axis.getAxis().getName().getValue();
_builder_15.append(_value_3);
_builder_15.append(", ");
String _literal_19 = outer_axis.getAxis().getName().getLiteral();
_builder_15.append(_literal_19);
_builder_15.append("No);");
_builder_15.newLineIfNotEmpty();
body = _builder_15.toString();
ChartOption _charttype_11 = chart.getCharttype();
if ((_charttype_11 instanceof ChartDonut)) {
StringConcatenation _builder_16 = new StringConcatenation();
_builder_16.append(body);
_builder_16.append("\tdataSeries.newSeries();");
_builder_16.newLineIfNotEmpty();
body = _builder_16.toString();
}
if (((!(chart.getCharttype() instanceof ChartPie)) && (!(chart.getCharttype() instanceof ChartDonut)))) {
StringConcatenation _builder_17 = new StringConcatenation();
_builder_17.append(body);
_builder_17.append("\tArrayList<Object> ");
String _literal_20 = inner_axis.getAxis().getName().getLiteral();
_builder_17.append(_literal_20);
_builder_17.append("DataSeries = new ArrayList<Object>();");
_builder_17.newLineIfNotEmpty();
body = _builder_17.toString();
}
StringConcatenation _builder_18 = new StringConcatenation();
_builder_18.append(body);
_builder_18.append("\tif(");
String _literal_21 = outer_axis.getAxis().getName().getLiteral();
_builder_18.append(_literal_21);
_builder_18.append("Pos.getMembers().get(0).getType() == MemberType.");
{
boolean _equals = Objects.equal(outer_axis, data_axis);
if (_equals) {
_builder_18.append("MEASURE");
} else {
_builder_18.append("REGULAR");
}
}
_builder_18.append(") {");
_builder_18.newLineIfNotEmpty();
body = _builder_18.toString();
StringConcatenation _builder_19 = new StringConcatenation();
_builder_19.append(body);
_builder_19.append("\t\tint ");
String _literal_22 = inner_axis.getAxis().getName().getLiteral();
_builder_19.append(_literal_22);
_builder_19.append("No = 0;");
_builder_19.newLineIfNotEmpty();
body = _builder_19.toString();
StringConcatenation _builder_20 = new StringConcatenation();
_builder_20.append(body);
_builder_20.append("\t\tfor\t(DerivedPosition ");
String _literal_23 = inner_axis.getAxis().getName().getLiteral();
_builder_20.append(_literal_23);
_builder_20.append("Pos : cellSet.getAxes().get(");
int _value_4 = inner_axis.getAxis().getName().getValue();
_builder_20.append(_value_4);
_builder_20.append(").getPositions()) {");
_builder_20.newLineIfNotEmpty();
body = _builder_20.toString();
StringConcatenation _builder_21 = new StringConcatenation();
_builder_21.append(body);
_builder_21.append("\t\t\tif(");
String _literal_24 = inner_axis.getAxis().getName().getLiteral();
_builder_21.append(_literal_24);
_builder_21.append("Pos.getMembers().get(0).getType() == MemberType.");
{
boolean _equals_1 = Objects.equal(inner_axis, data_axis);
if (_equals_1) {
_builder_21.append("MEASURE");
} else {
_builder_21.append("REGULAR");
}
}
_builder_21.append(") {");
_builder_21.newLineIfNotEmpty();
body = _builder_21.toString();
ChartOption _charttype_12 = chart.getCharttype();
if ((_charttype_12 instanceof ChartPie)) {
StringConcatenation _builder_22 = new StringConcatenation();
_builder_22.append(body);
_builder_22.append("\t\t\t\tdataSeries.newSeries();");
_builder_22.newLineIfNotEmpty();
body = _builder_22.toString();
}
StringConcatenation _builder_23 = new StringConcatenation();
_builder_23.append(body);
_builder_23.append("\t\t\t\tcoordinate.set(");
int _value_5 = inner_axis.getAxis().getName().getValue();
_builder_23.append(_value_5);
_builder_23.append(", ");
String _literal_25 = inner_axis.getAxis().getName().getLiteral();
_builder_23.append(_literal_25);
_builder_23.append("No);");
_builder_23.newLineIfNotEmpty();
body = _builder_23.toString();
StringConcatenation _builder_24 = new StringConcatenation();
_builder_24.append(body);
_builder_24.newLineIfNotEmpty();
_builder_24.append("\t\t\t\t");
_builder_24.append("Object value = null;");
_builder_24.newLine();
_builder_24.append("\t\t\t\t");
_builder_24.append("DerivedCell cell = cellSet.getCell(coordinate);");
_builder_24.newLine();
_builder_24.append("\t\t\t\t");
_builder_24.append("if (cell != null) {");
_builder_24.newLine();
_builder_24.append("\t\t\t\t\t");
_builder_24.append("value = cell.getValue();");
_builder_24.newLine();
_builder_24.append("\t\t\t\t");
_builder_24.append("}");
_builder_24.newLine();
body = _builder_24.toString();
if (((chart.getCharttype() instanceof ChartPie) || (chart.getCharttype() instanceof ChartDonut))) {
StringConcatenation _builder_25 = new StringConcatenation();
_builder_25.append(body);
_builder_25.append("\t\t\t\tdataSeries.add(");
String _literal_26 = outer_axis.getAxis().getName().getLiteral();
_builder_25.append(_literal_26);
_builder_25.append("TitlesArray.get(");
String _literal_27 = outer_axis.getAxis().getName().getLiteral();
_builder_25.append(_literal_27);
_builder_25.append("No)+\" \"+");
String _literal_28 = inner_axis.getAxis().getName().getLiteral();
_builder_25.append(_literal_28);
_builder_25.append("TitlesArray.get(");
String _literal_29 = inner_axis.getAxis().getName().getLiteral();
_builder_25.append(_literal_29);
_builder_25.append("No),(value == null ? 0.0 : value));");
_builder_25.newLineIfNotEmpty();
body = _builder_25.toString();
} else {
StringConcatenation _builder_26 = new StringConcatenation();
_builder_26.append(body);
_builder_26.append("\t\t\t\t");
String _literal_30 = inner_axis.getAxis().getName().getLiteral();
_builder_26.append(_literal_30);
_builder_26.append("DataSeries.add(value == null ? 0.0 : value);");
_builder_26.newLineIfNotEmpty();
body = _builder_26.toString();
}
StringConcatenation _builder_27 = new StringConcatenation();
_builder_27.append(body);
_builder_27.append("\t\t\t\t");
String _literal_31 = inner_axis.getAxis().getName().getLiteral();
_builder_27.append(_literal_31);
_builder_27.append("No ++;");
_builder_27.newLineIfNotEmpty();
_builder_27.append("\t\t\t");
_builder_27.append("}");
_builder_27.newLine();
_builder_27.append("\t\t");
_builder_27.append("}");
_builder_27.newLine();
body = _builder_27.toString();
if (((!(chart.getCharttype() instanceof ChartPie)) && (!(chart.getCharttype() instanceof ChartDonut)))) {
ChartOption _charttype_13 = chart.getCharttype();
if ((_charttype_13 instanceof ChartBubble)) {
StringConcatenation _builder_28 = new StringConcatenation();
_builder_28.append(body);
_builder_28.append("\t\t\t");
String _literal_32 = inner_axis.getAxis().getName().getLiteral();
_builder_28.append(_literal_32);
_builder_28.append("DataSeries.add(");
String _literal_33 = outer_axis.getAxis().getName().getLiteral();
_builder_28.append(_literal_33);
_builder_28.append("TitlesArray.get(");
String _literal_34 = outer_axis.getAxis().getName().getLiteral();
_builder_28.append(_literal_34);
_builder_28.append("No));");
_builder_28.newLineIfNotEmpty();
body = _builder_28.toString();
}
StringConcatenation _builder_29 = new StringConcatenation();
_builder_29.append(body);
_builder_29.append("\t\tdataSeries.add(");
String _literal_35 = inner_axis.getAxis().getName().getLiteral();
_builder_29.append(_literal_35);
_builder_29.append("DataSeries.toArray());");
_builder_29.newLineIfNotEmpty();
body = _builder_29.toString();
}
StringConcatenation _builder_30 = new StringConcatenation();
_builder_30.append(body);
_builder_30.append("\t}");
_builder_30.newLineIfNotEmpty();
_builder_30.append("\t");
String _literal_36 = outer_axis.getAxis().getName().getLiteral();
_builder_30.append(_literal_36, "\t");
_builder_30.append("No ++;");
_builder_30.newLineIfNotEmpty();
_builder_30.append("}");
_builder_30.newLine();
body = _builder_30.toString();
StringConcatenation _builder_31 = new StringConcatenation();
_builder_31.append(body);
_builder_31.append("SeriesDefaults seriesDefaults = new SeriesDefaults()");
_builder_31.newLineIfNotEmpty();
_builder_31.append("\t");
_builder_31.append(".setRenderer(SeriesRenderers.");
_builder_31.append(chartType, "\t");
_builder_31.append(");");
_builder_31.newLineIfNotEmpty();
body = _builder_31.toString();
ChartOption _charttype_14 = chart.getCharttype();
if ((_charttype_14 instanceof ChartLine)) {
StringConcatenation _builder_32 = new StringConcatenation();
_builder_32.append(body);
_builder_32.append("seriesDefaults.setFillToZero(");
ChartOption _charttype_15 = chart.getCharttype();
String _string = Boolean.valueOf(Boolean.valueOf(((ChartLine) _charttype_15).isFillToZero()).booleanValue()).toString();
_builder_32.append(_string);
_builder_32.append(").setFill(");
ChartOption _charttype_16 = chart.getCharttype();
String _string_1 = Boolean.valueOf(((ChartLine) _charttype_16).isFillArea()).toString();
_builder_32.append(_string_1);
_builder_32.append(");");
_builder_32.newLineIfNotEmpty();
body = _builder_32.toString();
ChartOption _charttype_17 = chart.getCharttype();
boolean _isTrendLine = ((ChartLine) _charttype_17).isTrendLine();
if (_isTrendLine) {
StringConcatenation _builder_33 = new StringConcatenation();
_builder_33.append(body);
_builder_33.append("seriesDefaults.setTrendline(");
_builder_33.newLineIfNotEmpty();
_builder_33.append("\t");
_builder_33.append("new Trendline().setShow(true).setLineWidth(1));");
_builder_33.newLine();
body = _builder_33.toString();
}
}
StringConcatenation _builder_34 = new StringConcatenation();
_builder_34.append(body);
_builder_34.append("Options options = new Options()");
_builder_34.newLineIfNotEmpty();
_builder_34.append("\t");
_builder_34.append(".setSeriesDefaults(seriesDefaults);");
_builder_34.newLine();
body = _builder_34.toString();
ChartOption _charttype_18 = chart.getCharttype();
if ((_charttype_18 instanceof ChartPie)) {
StringConcatenation _builder_35 = new StringConcatenation();
_builder_35.append(body);
_builder_35.append("seriesDefaults.setRendererOptions(new PieRenderer()");
_builder_35.newLineIfNotEmpty();
_builder_35.append("\t");
_builder_35.append(".setShowDataLabels(true).setFill(");
ChartOption _charttype_19 = chart.getCharttype();
boolean _isEmpty = ((ChartPie) _charttype_19).isEmpty();
String _string_2 = Boolean.valueOf((!_isEmpty)).toString();
_builder_35.append(_string_2, "\t");
_builder_35.append("));");
_builder_35.newLineIfNotEmpty();
body = _builder_35.toString();
} else {
ChartOption _charttype_20 = chart.getCharttype();
if ((_charttype_20 instanceof ChartDonut)) {
StringConcatenation _builder_36 = new StringConcatenation();
_builder_36.append(body);
_builder_36.append("seriesDefaults.setRendererOptions(new DonutRenderer()");
_builder_36.newLineIfNotEmpty();
_builder_36.append("\t");
_builder_36.append(".setShowDataLabels(true)");
_builder_36.newLine();
_builder_36.append("\t");
_builder_36.append(".setStartAngle(-90)");
_builder_36.newLine();
_builder_36.append("\t");
_builder_36.append(".setSliceMargin(3));");
_builder_36.newLine();
body = _builder_36.toString();
} else {
ChartOption _charttype_21 = chart.getCharttype();
if ((_charttype_21 instanceof ChartBubble)) {
StringConcatenation _builder_37 = new StringConcatenation();
_builder_37.append(body);
_builder_37.append("seriesDefaults.setRendererOptions(new BubbleRenderer()");
_builder_37.newLineIfNotEmpty();
_builder_37.append("\t");
_builder_37.append(".setVaryBubbleColors(true)");
_builder_37.newLine();
_builder_37.append("\t");
{
ChartOption _charttype_22 = chart.getCharttype();
boolean _isMultiplier = ((ChartBubble) _charttype_22).isMultiplier();
if (_isMultiplier) {
_builder_37.append(".setAutoscaleMultiplier(");
ChartOption _charttype_23 = chart.getCharttype();
String _multiplierValue = ((ChartBubble) _charttype_23).getMultiplierValue();
_builder_37.append(_multiplierValue, "\t");
_builder_37.append("f)");
}
}
_builder_37.newLineIfNotEmpty();
_builder_37.append(" ");
{
ChartOption _charttype_24 = chart.getCharttype();
boolean _isTransparent = ((ChartBubble) _charttype_24).isTransparent();
if (_isTransparent) {
_builder_37.append(".setHighlightAlpha(0.8f).setBubbleAlpha(0.6f)");
}
}
_builder_37.newLineIfNotEmpty();
_builder_37.append("\t");
{
ChartOption _charttype_25 = chart.getCharttype();
boolean _isGradient = ((ChartBubble) _charttype_25).isGradient();
if (_isGradient) {
_builder_37.append(".setBubbleGradients(true)");
}
}
_builder_37.newLineIfNotEmpty();
_builder_37.append("\t");
_builder_37.append(".setShowLabels(false)");
_builder_37.newLine();
_builder_37.append("\t");
_builder_37.append(".setAutoscaleBubbles(true));");
_builder_37.newLine();
body = _builder_37.toString();
} else {
ChartOption _charttype_26 = chart.getCharttype();
if ((_charttype_26 instanceof ChartGauge)) {
String intervalValues = "";
String intervalColors = "";
ChartOption _charttype_27 = chart.getCharttype();
boolean _isHasIntervals = ((ChartGauge) _charttype_27).isHasIntervals();
if (_isHasIntervals) {
ChartOption _charttype_28 = chart.getCharttype();
EList<ChartInterval> _intervals = ((ChartGauge) _charttype_28).getIntervals();
for (final ChartInterval interval : _intervals) {
if ((interval instanceof ChartNumberInterval)) {
StringConcatenation _builder_38 = new StringConcatenation();
_builder_38.append(intervalValues);
{
int _length = intervalValues.length();
boolean _greaterThan = (_length > 0);
if (_greaterThan) {
_builder_38.append(",");
}
}
int _numberIntervalValue = ((ChartNumberInterval) interval).getNumberIntervalValue();
_builder_38.append(_numberIntervalValue);
_builder_38.append("f");
intervalValues = _builder_38.toString();
ChartRangeElement _numberRange = ((ChartNumberInterval) interval).getNumberRange();
if ((_numberRange instanceof ChartSegmentColor)) {
StringConcatenation _builder_39 = new StringConcatenation();
_builder_39.append(intervalColors);
{
int _length_1 = intervalColors.length();
boolean _greaterThan_1 = (_length_1 > 0);
if (_greaterThan_1) {
_builder_39.append(",");
}
}
_builder_39.append("\"");
ChartRangeElement _numberRange_1 = ((ChartNumberInterval) interval).getNumberRange();
String _hex = this.toHex(((ChartSegmentColor) _numberRange_1).getRgb());
_builder_39.append(_hex);
_builder_39.append("\"");
intervalColors = _builder_39.toString();
}
}
}
}
StringConcatenation _builder_40 = new StringConcatenation();
_builder_40.append(body);
_builder_40.append("seriesDefaults.setRendererOptions(new MeterGaugeRenderer()");
_builder_40.newLineIfNotEmpty();
_builder_40.append("\t");
_builder_40.append(".setShowTickLabels(");
ChartOption _charttype_29 = chart.getCharttype();
String _string_3 = Boolean.valueOf(((ChartGauge) _charttype_29).isHasTicks()).toString();
_builder_40.append(_string_3, "\t");
_builder_40.append(")");
_builder_40.newLineIfNotEmpty();
_builder_40.append("\t");
{
ChartOption _charttype_30 = chart.getCharttype();
boolean _isLabeled = ((ChartGauge) _charttype_30).isLabeled();
if (_isLabeled) {
_builder_40.append(".setLabel(\"");
ChartOption _charttype_31 = chart.getCharttype();
String _labelValue = ((ChartGauge) _charttype_31).getLabelValue();
_builder_40.append(_labelValue, "\t");
_builder_40.append("\")");
}
}
_builder_40.newLineIfNotEmpty();
_builder_40.append("\t");
{
ChartOption _charttype_32 = chart.getCharttype();
boolean _isHasIntervals_1 = ((ChartGauge) _charttype_32).isHasIntervals();
if (_isHasIntervals_1) {
_builder_40.append(".setIntervals(");
_builder_40.append(intervalValues, "\t");
_builder_40.append(")");
}
}
_builder_40.newLineIfNotEmpty();
_builder_40.append("\t");
{
ChartOption _charttype_33 = chart.getCharttype();
boolean _isHasIntervals_2 = ((ChartGauge) _charttype_33).isHasIntervals();
if (_isHasIntervals_2) {
_builder_40.append(".setIntervalColors(");
_builder_40.append(intervalColors, "\t");
_builder_40.append(")");
}
}
_builder_40.append(");");
_builder_40.newLineIfNotEmpty();
body = _builder_40.toString();
} else {
ChartOption _charttype_34 = chart.getCharttype();
if ((_charttype_34 instanceof ChartBar)) {
StringConcatenation _builder_41 = new StringConcatenation();
_builder_41.append(body);
_builder_41.append("seriesDefaults.setFillToZero(true);");
_builder_41.newLineIfNotEmpty();
_builder_41.append("seriesDefaults.setRendererOptions(new BarRenderer()");
_builder_41.newLine();
_builder_41.append(" ");
{
if (axisSwitch) {
_builder_41.append(".setBarDirection(BarDirections.HOTIZONTAL));");
} else {
_builder_41.append(".setBarDirection(BarDirections.VERTICAL));");
}
}
_builder_41.newLineIfNotEmpty();
body = _builder_41.toString();
ChartOption _charttype_35 = chart.getCharttype();
boolean _isStacked = ((ChartBar) _charttype_35).isStacked();
if (_isStacked) {
StringConcatenation _builder_42 = new StringConcatenation();
_builder_42.append(body);
_builder_42.append("options.setStackSeries(true);");
_builder_42.newLineIfNotEmpty();
body = _builder_42.toString();
}
ChartOption _charttype_36 = chart.getCharttype();
boolean _isShadow = ((ChartBar) _charttype_36).isShadow();
if (_isShadow) {
StringConcatenation _builder_43 = new StringConcatenation();
_builder_43.append(body);
_builder_43.append("seriesDefaults.setShadow(true).setShadowAlpha(0.05f);");
_builder_43.newLineIfNotEmpty();
body = _builder_43.toString();
}
ChartOption _charttype_37 = chart.getCharttype();
boolean _isAnimated = ((ChartBar) _charttype_37).isAnimated();
if (_isAnimated) {
StringConcatenation _builder_44 = new StringConcatenation();
_builder_44.append(body);
_builder_44.append("options.setAnimate(true);");
_builder_44.newLineIfNotEmpty();
body = _builder_44.toString();
}
}
}
}
}
}
StringConcatenation _builder_45 = new StringConcatenation();
_builder_45.append(body);
_builder_45.newLineIfNotEmpty();
_builder_45.append("String[] seriesColors = {\"#98E958\",\"#3090F0\",\"#EC6464\",\"#F9DD51\",\"#24DCD4\",\"#EC64A5\",\"#685CB0\",\"#FF7D42\",\"#AA514D\",\"#7FB053\",\"#BBA85B\",\"#247981\"};");
_builder_45.newLine();
_builder_45.append("options.setSeriesColors(seriesColors);");
_builder_45.newLine();
body = _builder_45.toString();
if (hasAxis) {
StringConcatenation _builder_46 = new StringConcatenation();
_builder_46.append(body);
_builder_46.append("Axes axes = new Axes();");
_builder_46.newLineIfNotEmpty();
body = _builder_46.toString();
ChartOption _charttype_38 = chart.getCharttype();
if ((_charttype_38 instanceof ChartBubble)) {
StringConcatenation _builder_47 = new StringConcatenation();
_builder_47.append(body);
_builder_47.append("CanvasAxisTickRenderer axisTickRenderer = new CanvasAxisTickRenderer();");
_builder_47.newLineIfNotEmpty();
_builder_47.append("axisTickRenderer.setTextColor(\"#202020\");");
_builder_47.newLine();
_builder_47.append("if (");
String _literal_37 = data_axis.getAxis().getName().getLiteral();
_builder_47.append(_literal_37);
_builder_47.append("TitlesArray.size() > 0) {");
_builder_47.newLineIfNotEmpty();
_builder_47.append("\t");
_builder_47.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt = axisPrefix.charAt(0);
_builder_47.append(_charAt, "\t");
_builder_47.append(").setLabel(");
String _literal_38 = data_axis.getAxis().getName().getLiteral();
_builder_47.append(_literal_38, "\t");
_builder_47.append("TitlesArray.get(0)).setTickOptions(axisTickRenderer");
{
int _angle = category_axis.getAngle();
boolean _notEquals = (_angle != 0);
if (_notEquals) {
_builder_47.append(".setAngle(");
int _angle_1 = data_axis.getAngle();
_builder_47.append(_angle_1, "\t");
_builder_47.append(")");
}
}
_builder_47.append("));");
_builder_47.newLineIfNotEmpty();
_builder_47.append("\t");
_builder_47.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_1 = axisPrefix.charAt(1);
_builder_47.append(_charAt_1, "\t");
_builder_47.append(").setLabel(");
String _literal_39 = data_axis.getAxis().getName().getLiteral();
_builder_47.append(_literal_39, "\t");
_builder_47.append("TitlesArray.get(1)).setTickOptions(axisTickRenderer");
{
int _angle_2 = category_axis.getAngle();
boolean _notEquals_1 = (_angle_2 != 0);
if (_notEquals_1) {
_builder_47.append(".setAngle(");
int _angle_3 = data_axis.getAngle();
_builder_47.append(_angle_3, "\t");
_builder_47.append(")");
}
}
_builder_47.append("));");
_builder_47.newLineIfNotEmpty();
_builder_47.append("\t");
_builder_47.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_2 = axisPrefix.charAt(1);
_builder_47.append(_charAt_2, "\t");
_builder_47.append("2).setLabel(");
String _literal_40 = data_axis.getAxis().getName().getLiteral();
_builder_47.append(_literal_40, "\t");
_builder_47.append("TitlesArray.get(2)).setTickOptions(axisTickRenderer");
{
int _angle_4 = category_axis.getAngle();
boolean _notEquals_2 = (_angle_4 != 0);
if (_notEquals_2) {
_builder_47.append(".setAngle(");
int _angle_5 = data_axis.getAngle();
_builder_47.append(_angle_5, "\t");
_builder_47.append(")");
}
}
_builder_47.append("));");
_builder_47.newLineIfNotEmpty();
_builder_47.append("}");
_builder_47.newLine();
body = _builder_47.toString();
} else {
StringConcatenation _builder_48 = new StringConcatenation();
_builder_48.append(body);
_builder_48.append("CanvasAxisTickRenderer tickRenderer = new CanvasAxisTickRenderer();");
_builder_48.newLineIfNotEmpty();
_builder_48.append("tickRenderer.setTextColor(\"#202020\");");
_builder_48.newLine();
_builder_48.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_3 = axisPrefix.charAt(0);
_builder_48.append(_charAt_3);
_builder_48.append(")");
_builder_48.newLineIfNotEmpty();
_builder_48.append("\t");
_builder_48.append(".setRenderer(AxisRenderers.");
String _string_4 = category_axis.getRenderType().name().toString();
_builder_48.append(_string_4, "\t");
_builder_48.append(")");
_builder_48.newLineIfNotEmpty();
_builder_48.append("\t");
_builder_48.append(".setLabel(");
String _literal_41 = category_axis.getAxis().getName().getLiteral();
_builder_48.append(_literal_41, "\t");
_builder_48.append("AxisLabel)");
_builder_48.newLineIfNotEmpty();
_builder_48.append("\t");
_builder_48.append(".setTicks(");
String _literal_42 = category_axis.getAxis().getName().getLiteral();
_builder_48.append(_literal_42, "\t");
_builder_48.append("Ticks)");
_builder_48.newLineIfNotEmpty();
_builder_48.append("\t");
_builder_48.append(".setTickOptions(tickRenderer");
{
int _angle_6 = category_axis.getAngle();
boolean _notEquals_3 = (_angle_6 != 0);
if (_notEquals_3) {
_builder_48.append(".setAngle(");
int _angle_7 = category_axis.getAngle();
_builder_48.append(_angle_7, "\t");
_builder_48.append(")");
}
}
_builder_48.append("));");
_builder_48.newLineIfNotEmpty();
body = _builder_48.toString();
StringConcatenation _builder_49 = new StringConcatenation();
_builder_49.append(body);
_builder_49.append("CanvasAxisTickRenderer axisTickRenderer = new CanvasAxisTickRenderer();");
_builder_49.newLineIfNotEmpty();
_builder_49.append("axisTickRenderer.setTextColor(\"#202020\");");
_builder_49.newLine();
_builder_49.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_4 = axisPrefix.charAt(1);
_builder_49.append(_charAt_4);
_builder_49.append(")");
_builder_49.newLineIfNotEmpty();
_builder_49.append("\t");
_builder_49.append(".setPad(1.05f)");
_builder_49.newLine();
_builder_49.append("\t");
_builder_49.append(".setTickOptions(axisTickRenderer");
{
int _angle_8 = data_axis.getAngle();
boolean _notEquals_4 = (_angle_8 != 0);
if (_notEquals_4) {
_builder_49.append(".setAngle(");
int _angle_9 = data_axis.getAngle();
_builder_49.append(_angle_9, "\t");
_builder_49.append(")");
}
}
_builder_49.append("));");
_builder_49.newLineIfNotEmpty();
body = _builder_49.toString();
Set<String> _keySet = multipleAxes.keySet();
for (final String axisKey : _keySet) {
boolean _equals_2 = axisKey.equals("1");
boolean _not = (!_equals_2);
if (_not) {
StringConcatenation _builder_50 = new StringConcatenation();
_builder_50.append(body);
String _get = multipleAxes.get(axisKey);
_builder_50.append(_get);
body = _builder_50.toString();
}
}
int _size = multipleAxes.keySet().size();
boolean _greaterThan_2 = (_size > 0);
if (_greaterThan_2) {
StringConcatenation _builder_51 = new StringConcatenation();
_builder_51.append(body);
_builder_51.append("LinearAxisRenderer linearAxisRenderer = new LinearAxisRenderer();");
_builder_51.newLineIfNotEmpty();
_builder_51.append("linearAxisRenderer.setAlignTicks(true);");
_builder_51.newLine();
_builder_51.append("AxesDefaults axesDefaults = new AxesDefaults()");
_builder_51.newLine();
_builder_51.append("\t");
_builder_51.append(".setUseSeriesColor(true)");
_builder_51.newLine();
_builder_51.append("\t");
_builder_51.append(".setBorderWidth(3)\t");
_builder_51.newLine();
_builder_51.append("\t");
_builder_51.append(".setRendererOptions(linearAxisRenderer);");
_builder_51.newLine();
_builder_51.append("options.setAxesDefaults(axesDefaults);");
_builder_51.newLine();
body = _builder_51.toString();
}
}
StringConcatenation _builder_52 = new StringConcatenation();
_builder_52.append(body);
_builder_52.append("options.setAxes(axes);");
_builder_52.newLineIfNotEmpty();
body = _builder_52.toString();
}
EList<ChartElement> _elements_1 = chart.getSource().getElements();
for (final ChartElement element_1 : _elements_1) {
if ((element_1 instanceof ChartLegend)) {
ChartLegend legend = ((ChartLegend) element_1);
StringConcatenation _builder_53 = new StringConcatenation();
_builder_53.append(body);
_builder_53.append("Legend legend = new Legend().setShow(");
String _string_5 = Boolean.valueOf(Boolean.valueOf((legend != null)).booleanValue()).toString();
_builder_53.append(_string_5);
_builder_53.append(");");
_builder_53.newLineIfNotEmpty();
body = _builder_53.toString();
StringConcatenation _builder_54 = new StringConcatenation();
_builder_54.append(body);
_builder_54.append("legend.setPlacement(LegendPlacements.");
String _name = legend.getPlacement().name();
_builder_54.append(_name);
_builder_54.append(");");
_builder_54.newLineIfNotEmpty();
body = _builder_54.toString();
boolean _isToggle = legend.isToggle();
if (_isToggle) {
StringConcatenation _builder_55 = new StringConcatenation();
_builder_55.append(body);
_builder_55.append("EnhancedLegendRenderer renderer = new EnhancedLegendRenderer();");
_builder_55.newLineIfNotEmpty();
_builder_55.append("renderer.setSeriesToggle(SeriesToggles.");
String _name_1 = legend.getToggleType().getName();
_builder_55.append(_name_1);
_builder_55.append(");");
_builder_55.newLineIfNotEmpty();
_builder_55.append("renderer.setSeriesToggleReplot(");
String _string_6 = Boolean.valueOf(Boolean.valueOf(legend.isReplot()).booleanValue()).toString();
_builder_55.append(_string_6);
_builder_55.append(");");
_builder_55.newLineIfNotEmpty();
_builder_55.append("legend.setRendererOptions(renderer);");
_builder_55.newLine();
body = _builder_55.toString();
}
StringConcatenation _builder_56 = new StringConcatenation();
_builder_56.append(body);
_builder_56.append("options.setLegend(legend);");
_builder_56.newLineIfNotEmpty();
body = _builder_56.toString();
}
}
EList<ChartElement> _elements_2 = chart.getSource().getElements();
for (final ChartElement element_2 : _elements_2) {
if ((element_2 instanceof ChartHighlighter)) {
ChartHighlighter highlighter = ((ChartHighlighter) element_2);
StringConcatenation _builder_57 = new StringConcatenation();
_builder_57.append(body);
_builder_57.append("Highlighter highlighter = new Highlighter().setShow(");
String _string_7 = Boolean.valueOf(Boolean.valueOf((highlighter != null)).booleanValue()).toString();
_builder_57.append(_string_7);
_builder_57.append(");");
_builder_57.newLineIfNotEmpty();
body = _builder_57.toString();
StringConcatenation _builder_58 = new StringConcatenation();
_builder_58.append(body);
_builder_58.append("highlighter.setShowTooltip(true)");
_builder_58.newLineIfNotEmpty();
_builder_58.append(".setTooltipAlwaysVisible(");
String _string_8 = Boolean.valueOf(Boolean.valueOf(highlighter.isTooltipAlways()).booleanValue()).toString();
_builder_58.append(_string_8);
_builder_58.append(")");
_builder_58.newLineIfNotEmpty();
_builder_58.append(".setKeepTooltipInsideChart(");
String _string_9 = Boolean.valueOf(Boolean.valueOf(highlighter.isInsideChart()).booleanValue()).toString();
_builder_58.append(_string_9);
_builder_58.append(")");
_builder_58.newLineIfNotEmpty();
_builder_58.append(".setTooltipLocation(TooltipLocations.");
String _name_2 = highlighter.getLocation().name();
_builder_58.append(_name_2);
_builder_58.append(")");
_builder_58.newLineIfNotEmpty();
_builder_58.append(".setBringSeriesToFront(true)");
_builder_58.newLine();
_builder_58.append(".setFadeTooltip(true)");
_builder_58.newLine();
_builder_58.append(".setShowMarker(true);");
_builder_58.newLine();
body = _builder_58.toString();
StringConcatenation _builder_59 = new StringConcatenation();
_builder_59.append(body);
_builder_59.append("highlighter.setTooltipAxes(TooltipAxes.");
_builder_59.append(axisPrefix);
_builder_59.append(postfix);
_builder_59.append(");");
_builder_59.newLineIfNotEmpty();
body = _builder_59.toString();
StringConcatenation _builder_60 = new StringConcatenation();
_builder_60.append(body);
_builder_60.append("options.setHighlighter(highlighter);");
_builder_60.newLineIfNotEmpty();
body = _builder_60.toString();
}
}
ChartOption _charttype_39 = chart.getCharttype();
if ((_charttype_39 instanceof ChartLine)) {
ChartOption _charttype_40 = chart.getCharttype();
boolean _isCursor = ((ChartLine) _charttype_40).isCursor();
if (_isCursor) {
StringConcatenation _builder_61 = new StringConcatenation();
_builder_61.append(body);
_builder_61.append("Cursor cursor = new Cursor()");
_builder_61.newLineIfNotEmpty();
_builder_61.append("\t");
_builder_61.append(".setShow(true)");
_builder_61.newLine();
_builder_61.append("\t");
_builder_61.append(".setZoom(");
ChartOption _charttype_41 = chart.getCharttype();
String _string_10 = Boolean.valueOf(((ChartLine) _charttype_41).isZoom()).toString();
_builder_61.append(_string_10, "\t");
_builder_61.append(")");
_builder_61.newLineIfNotEmpty();
_builder_61.append("\t");
_builder_61.append(".setShowTooltip(");
ChartOption _charttype_42 = chart.getCharttype();
String _string_11 = Boolean.valueOf(((ChartLine) _charttype_42).isTooltip()).toString();
_builder_61.append(_string_11, "\t");
_builder_61.append(");");
_builder_61.newLineIfNotEmpty();
_builder_61.append("options.setCursor(cursor);");
_builder_61.newLine();
body = _builder_61.toString();
}
ChartOption _charttype_43 = chart.getCharttype();
boolean _isAnimated_1 = ((ChartLine) _charttype_43).isAnimated();
if (_isAnimated_1) {
StringConcatenation _builder_62 = new StringConcatenation();
_builder_62.append(body);
_builder_62.append("options.setAnimate(true);");
_builder_62.newLineIfNotEmpty();
body = _builder_62.toString();
}
}
if (hasAxis) {
StringConcatenation _builder_63 = new StringConcatenation();
_builder_63.append(body);
_builder_63.append("options.setSeries(");
String _literal_43 = data_axis.getAxis().getName().getLiteral();
_builder_63.append(_literal_43);
_builder_63.append("Series);");
_builder_63.newLineIfNotEmpty();
body = _builder_63.toString();
}
StringConcatenation _builder_64 = new StringConcatenation();
_builder_64.append(body);
_builder_64.append("DCharts chart = new DCharts();");
_builder_64.newLineIfNotEmpty();
_builder_64.append("chart.setDataSeries(dataSeries);");
_builder_64.newLine();
_builder_64.append("chart.setOptions(options);");
_builder_64.newLine();
_builder_64.append("chart.setEnableDownload(true);");
_builder_64.newLine();
_builder_64.append("chart.setDownloadButtonCaption(dslMetadataService.translate(user.getLocale().toLanguageTag(), \"download\"));");
_builder_64.newLine();
_builder_64.append("chart.setDownloadFilename(\"");
String _name_3 = chart.getName();
_builder_64.append(_name_3);
_builder_64.append("\");");
_builder_64.newLineIfNotEmpty();
_builder_64.append("chart.setDownloadButtonLocation(DownloadButtonLocation.TOP_RIGHT);");
_builder_64.newLine();
body = _builder_64.toString();
StringConcatenation _builder_65 = new StringConcatenation();
_builder_65.append(body);
_builder_65.append("chart.setId(\"chart\");");
_builder_65.newLineIfNotEmpty();
_builder_65.append("chart.setImmediate(true);");
_builder_65.newLine();
_builder_65.append("if(chartRefresherDone) {");
_builder_65.newLine();
_builder_65.append("\t");
_builder_65.append("chart.show();");
_builder_65.newLine();
_builder_65.append("}");
_builder_65.newLine();
_builder_65.append("charts.add(chart);");
_builder_65.newLine();
_builder_65.append("return chart;");
body = _builder_65.toString();
return body;
}
/**
* <p>helper method to convert a rgb string to a hex string.</p>
*/
public String toHex(final String rgb) {
String colorHex = "#";
String[] _split = rgb.split(",");
for (final String color : _split) {
{
Integer i = new Integer(color);
StringConcatenation _builder = new StringConcatenation();
_builder.append(colorHex);
String _format = String.format("%02x", i);
_builder.append(_format);
colorHex = _builder.toString();
}
}
return colorHex;
}
/**
* <p>build the label series. Create multiple y-axes when the underlying datamart presents different scales.</p>
*
* <p>scales are used to display line charts together for comparison reason but they are of different scalings.</p>
*/
public String createLabelSeries(final Chart chart, final ChartAxis data_axis, final HashMap<String, String> multipleAxes, final String axisPrefix, final boolean showMarker) {
String body = "";
int msrCnt = 0;
ChartDatamart _source = chart.getSource();
DatamartSource _source_1 = ((ChartDatamart) _source).getDatamartRef().getSource();
if ((_source_1 instanceof DatamartCube)) {
ChartDatamart _source_2 = chart.getSource();
DatamartSource _source_3 = ((ChartDatamart) _source_2).getDatamartRef().getSource();
EList<DatamartCubeElement> _axisslicer = ((DatamartCube) _source_3).getAxisslicer();
for (final DatamartCubeElement axisOrSlicer : _axisslicer) {
if ((axisOrSlicer instanceof DatamartCubeAxis)) {
EList<DatamartElement> _elements = ((DatamartCubeAxis) axisOrSlicer).getElements();
for (final DatamartElement element : _elements) {
{
if ((element instanceof DatamartDerivedMeasure)) {
boolean _isScaled = ((DatamartDerivedMeasure) element).isScaled();
if (_isScaled) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
String _createScale = this.createScale(((DatamartDerivedMeasure) element).getScale(), data_axis, multipleAxes, msrCnt, axisPrefix, showMarker);
_builder.append(_createScale);
body = _builder.toString();
msrCnt = (msrCnt + 1);
}
}
if ((element instanceof DatamartMeasure)) {
boolean _isScaled_1 = ((DatamartMeasure) element).isScaled();
if (_isScaled_1) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
String _createScale_1 = this.createScale(((DatamartMeasure) element).getScale(), data_axis, multipleAxes, msrCnt, axisPrefix, showMarker);
_builder_1.append(_createScale_1);
body = _builder_1.toString();
msrCnt = (msrCnt + 1);
}
}
}
}
}
}
} else {
ChartDatamart _source_4 = chart.getSource();
DatamartSource _source_5 = ((ChartDatamart) _source_4).getDatamartRef().getSource();
if ((_source_5 instanceof DatamartEntity)) {
ChartDatamart _source_6 = chart.getSource();
DatamartSource _source_7 = ((ChartDatamart) _source_6).getDatamartRef().getSource();
DatamartEntity entity = ((DatamartEntity) _source_7);
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
String _entityScale = this.entityScale(entity, data_axis, multipleAxes, msrCnt, axisPrefix, showMarker);
_builder.append(_entityScale);
body = _builder.toString();
}
}
int _size = multipleAxes.keySet().size();
boolean _equals = (_size == 0);
if (_equals) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.append("\tfor (String title : ");
String _literal = data_axis.getAxis().getName().getLiteral();
_builder_1.append(_literal);
_builder_1.append("TitlesArray) {");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
String _literal_1 = data_axis.getAxis().getName().getLiteral();
_builder_1.append(_literal_1, "\t\t");
_builder_1.append("Series.addSeries(new XYseries().setLabel(title).setShowMarker(");
String _string = Boolean.valueOf(showMarker).toString();
_builder_1.append(_string, "\t\t");
_builder_1.append("));");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
body = _builder_1.toString();
}
return body;
}
/**
* <p>helper method for scales coming from datamart entities not from cubes.</p>
*/
public String entityScale(final DatamartEntity entity, final ChartAxis data_axis, final HashMap<String, String> multipleAxes, final int msrCnt, final String axisPrefix, final boolean showMarker) {
int counter = msrCnt;
String body = "";
EList<DatamartAttribute> _attributes = entity.getAttributes();
for (final DatamartAttribute attribute : _attributes) {
if ((attribute instanceof DatamartAttribute)) {
boolean _isScaled = attribute.isScaled();
if (_isScaled) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
String _createScale = this.createScale(attribute.getScale(), data_axis, multipleAxes, counter, axisPrefix, showMarker);
_builder.append(_createScale);
body = _builder.toString();
counter = (counter + 1);
}
}
}
EList<DatamartNavigation> _navigations = entity.getNavigations();
for (final DatamartNavigation navigation : _navigations) {
{
if ((navigation instanceof DatamartMember)) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
String _entityScale = this.entityScale(((DatamartMember) navigation).getDatamartEntity(), data_axis, multipleAxes, counter, axisPrefix, showMarker);
_builder_1.append(_entityScale);
body = _builder_1.toString();
}
if ((navigation instanceof DatamartOwner)) {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body);
String _entityScale_1 = this.entityScale(((DatamartOwner) navigation).getDatamartEntity(), data_axis, multipleAxes, counter, axisPrefix, showMarker);
_builder_2.append(_entityScale_1);
body = _builder_2.toString();
}
}
}
return body;
}
/**
* <p>helper method for scales.</p>
*/
public String createScale(final ValueScaleEnum scale, final ChartAxis data_axis, final HashMap<String, String> multipleAxes, final int msrCnt, final String axisPrefix, final boolean showMarker) {
String multipleBody = "";
String body = "";
int scaleOrdinal = scale.ordinal();
String scaleName = scale.toString();
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
_builder.newLineIfNotEmpty();
_builder.append("\t");
String _literal = data_axis.getAxis().getName().getLiteral();
_builder.append(_literal, "\t");
_builder.append("Series.addSeries(new XYseries(");
char _charAt = axisPrefix.charAt(1);
_builder.append(_charAt, "\t");
_builder.append("axes.");
char _charAt_1 = axisPrefix.charAt(1);
_builder.append(_charAt_1, "\t");
{
if ((scaleOrdinal != 0)) {
_builder.append((scaleOrdinal + 1), "\t");
}
}
_builder.append(").setLabel(");
String _literal_1 = data_axis.getAxis().getName().getLiteral();
_builder.append(_literal_1, "\t");
_builder.append("TitlesArray.get(");
_builder.append(msrCnt, "\t");
_builder.append(")).setShowMarker(");
String _string = Boolean.valueOf(showMarker).toString();
_builder.append(_string, "\t");
_builder.append("));");
_builder.newLineIfNotEmpty();
body = _builder.toString();
boolean _contains = multipleAxes.keySet().contains(scaleName);
boolean _not = (!_contains);
if (_not) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("axes.addAxis(new XYaxis(XYaxes.");
char _charAt_2 = axisPrefix.charAt(1);
_builder_1.append(_charAt_2);
{
if ((scaleOrdinal != 0)) {
_builder_1.append((scaleOrdinal + 1));
}
}
_builder_1.append(").setTickOptions(axisTickRenderer");
{
int _angle = data_axis.getAngle();
boolean _notEquals = (_angle != 0);
if (_notEquals) {
_builder_1.append(".setAngle(");
int _angle_1 = data_axis.getAngle();
_builder_1.append(_angle_1);
_builder_1.append(")");
}
}
_builder_1.append("));");
_builder_1.newLineIfNotEmpty();
multipleBody = _builder_1.toString();
multipleAxes.put(scaleName, multipleBody);
}
return body;
}
/**
* <p>helper method to get a attribute name or its alias if present of a entity's attribute object.</p>
*/
public String getAttributeName(final DatamartAttribute attribute) {
LEntityAttribute _attributeRef = attribute.getAttributeRef();
return ((LAttribute) _attributeRef).getName().toUpperCase();
}
/**
* <p>helper method to get a level name of a hierarchy's level object.</p>
*/
public String getLevelName(final CubeLevel level) {
return level.getName();
}
public String filterChanged(final Chart chart) {
String body = "";
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
_builder.newLineIfNotEmpty();
_builder.append("if(changedFilter != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, changedFilter.getName(), \"");
String _name = chart.getName();
_builder.append(_name, "\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("evnt.addData(changedFilter.getSelectedData());");
_builder.newLine();
_builder.append("\t");
_builder.append("eventDispatcher.sendEvent(evnt);");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("renderData();");
_builder.newLine();
body = _builder.toString();
return body;
}
public Set<LEntity> findRequestedEntities(final Chart chart) {
HashSet<LEntity> entities = new HashSet<LEntity>();
ChartDatamart _source = chart.getSource();
entities.addAll(this.datamartInferrer.findAllEntities(((ChartDatamart) _source).getDatamartRef()));
return entities;
}
public String receiveEvent(final Chart chart) {
String body = "";
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
_builder.newLineIfNotEmpty();
_builder.append("switch(event.getCommand()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("case SELECT:");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(!event.getSender().equals(\"");
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(chart);
_builder.append(_fullyQualifiedName, "\t\t");
_builder.append("\")) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("if(filterGenerator.selectItem(event, ");
boolean _booleanValue = Boolean.valueOf(chart.isSelectById()).booleanValue();
_builder.append(_booleanValue, "\t\t\t");
_builder.append(")) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t\t");
_builder.append("renderData();");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("break;");
_builder.newLine();
_builder.append("\t");
_builder.append("case SAVE:");
_builder.newLine();
_builder.append("\t");
_builder.append("case DELETE:");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(!event.getSender().equals(\"");
QualifiedName _fullyQualifiedName_1 = this._iQualifiedNameProvider.getFullyQualifiedName(chart);
_builder.append(_fullyQualifiedName_1, "\t\t");
_builder.append("\")) {");
_builder.newLineIfNotEmpty();
{
Set<LEntity> _findRequestedEntities = this.findRequestedEntities(chart);
for(final LEntity e : _findRequestedEntities) {
_builder.append("\t\t\t");
_builder.append("if(event.getTopic().equals(\"");
QualifiedName _fullyQualifiedName_2 = this._iQualifiedNameProvider.getFullyQualifiedName(e);
_builder.append(_fullyQualifiedName_2, "\t\t\t");
_builder.append("\")){");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t");
_builder.append("\t");
_builder.append("datamartInstance.clearCache();");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("\t");
_builder.append("renderData();");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("break;");
_builder.newLine();
_builder.append("}");
_builder.newLine();
body = _builder.toString();
return body;
}
public CharSequence localeChanged(final Chart chart) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("if(charts != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("for(DCharts chart:charts) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("chart.setLocale(locale);");
_builder.newLine();
{
if ((chart.getSource().getDatamartRef().isDescription() &&
(chart.getSource().getDatamartRef().getDescriptionValue() != null))) {
_builder.append("\t\t");
_builder.append("chart.setDescription(dslMetadataService.translate(locale.toLanguageTag(), \"");
String _descriptionValue = chart.getSource().getDatamartRef().getDescriptionValue();
_builder.append(_descriptionValue, "\t\t");
_builder.append("\"));");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("chart.setDownloadButtonCaption(dslMetadataService.translate(locale.toLanguageTag(), \"download\"));");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("if(layoutManager != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("layoutManager.setLabelValue(dslMetadataService.translate(locale.toLanguageTag(), \"");
String _name = chart.getName();
_builder.append(_name, "\t");
_builder.append("\"));");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
return _builder;
}
public void infer(final EObject pckg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
if (pckg instanceof ChartPackage) {
_infer((ChartPackage)pckg, acceptor, isPreIndexingPhase);
return;
} else if (pckg != null) {
_infer(pckg, acceptor, isPreIndexingPhase);
return;
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(pckg, acceptor, isPreIndexingPhase).toString());
}
}
}