Skip to content
Permalink
Browse files

Change project structure, moved to gradle

  • Loading branch information...
Vitaliy-Yakovchuk committed Oct 24, 2015
0 parents commit d82710362831f61875bd4e4645735a9d1f591668
Showing 1,455 changed files with 183,404 additions and 0 deletions.
@@ -0,0 +1,101 @@
# Created by https://www.gitignore.io/api/intellij,gradle,eclipse

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties


### Gradle ###
.gradle
build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar


### Eclipse ###
*.pydevproject
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath

# Eclipse Core
.project

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Java annotation processor (APT)
.factorypath

# PDT-specific
.buildpath

# sbteclipse plugin
.target

# TeXlipse plugin
.texlipse
@@ -0,0 +1,30 @@
group 'com.vitalex.ramus'
version '1.0-SNAPSHOT'

apply plugin: 'java'

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}

allprojects {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
sourceCompatibility = 1.6

sourceSets {
main {
java {
srcDirs = ['src/main/java', 'src/main/resources']
}
}
}
}
@@ -0,0 +1,14 @@
group 'com.vitalex.ramus'
version '1.0-SNAPSHOT'

apply plugin: 'java'

repositories {
mavenCentral()
}

dependencies {
compile project(':core-simple-attributes')
compile 'org.jfree:jfreechart:1.0.19'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
@@ -0,0 +1,37 @@
package com.ramussoft.chart;

import org.jfree.chart.JFreeChart;

import com.ramussoft.common.Element;
import com.ramussoft.common.Engine;
import com.ramussoft.core.attribute.standard.StandardAttributesPlugin;
import com.ramussoft.eval.EObject;

import static com.ramussoft.chart.ChartDataFramework.getPreferencesPath;

public abstract class AbstractChartDataPlugin implements ChartDataPlugin {

protected Engine engine;

public AbstractChartDataPlugin(Engine engine) {
this.engine = engine;
}

@Override
public JFreeChart createChart(Element element) {
String path = getPreferencesPath(element, StandardAttributesPlugin
.getAttributeNameAttribute(engine));
ChartSource source = new ChartSource(engine);
source.load(engine.getInputStream(path));
return createChart(element, source);
}

protected String toString(Object value) {
return new EObject(value).stringValue();
}

protected double toDouble(Object value) {
return new EObject(value).doubleValue();
}

}
@@ -0,0 +1,18 @@
package com.ramussoft.chart;

public abstract class AbstractSource implements XMLElement {

protected static final String ATTRIBUTE_ID = "attribute-id";

protected static final String SOURCE = "source";

protected ChartSource chartSource;

AbstractSource(ChartSource source) {
this.chartSource = source;
}

public ChartSource getChartSource() {
return chartSource;
}
}
@@ -0,0 +1,49 @@
package com.ramussoft.chart;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;

import com.ramussoft.common.Attribute;
import com.ramussoft.common.Engine;

public class AttributeSource extends AbstractSource implements XMLElement {

AttributeSource(ChartSource source) {
super(source);
}

private Attribute attribute;

@Override
public void load(Node node, Engine engine) {
NamedNodeMap attributes = node.getAttributes();
attribute = engine.getAttribute(Long.parseLong(attributes.getNamedItem(
ATTRIBUTE_ID).getNodeValue()));
}

@Override
public void save(ChartSaveXMLReader reader) throws SAXException {
AttributesImpl attrs = new AttributesImpl();
attrs.addAttribute("", ATTRIBUTE_ID, ATTRIBUTE_ID, "CDATA", Long
.toString(attribute.getId()));
reader.startElement(SOURCE, attrs);
reader.endElement(SOURCE);
}

/**
* @param attribute the attribute to set
*/
public void setAttribute(Attribute attribute) {
this.attribute = attribute;
}

/**
* @return the attribute
*/
public Attribute getAttribute() {
return attribute;
}

}
@@ -0,0 +1,72 @@
package com.ramussoft.chart;

import java.awt.Color;
import java.awt.GradientPaint;
import java.util.List;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer3D;
import org.jfree.data.category.DefaultCategoryDataset;

import com.ramussoft.common.Attribute;
import com.ramussoft.common.Element;
import com.ramussoft.common.Engine;
import com.ramussoft.eval.EObject;

public class BarChartDataPlugin extends AbstractChartDataPlugin implements
ChartConstants {

public BarChartDataPlugin(Engine engine) {
super(engine);
}

@Override
public JFreeChart createChart(Element element, ChartSource source) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();

Attribute key = source.getAttributeProperty(BAR_ATTRIBUTE_KEY);

List<Attribute> attributes = source
.getPropertyAttributes(BAR_ATTRIBUTE_VALUE_PREFIX);

for (Element e : source.getElements()) {
Object keyValue = engine.getAttribute(e, key);
if (keyValue != null) {
for (Attribute attribute : attributes) {
Object value = engine.getAttribute(e, attribute);
if (value != null) {
double v = new EObject(value).doubleValue();
dataset.addValue(v, attribute.getName(), new EObject(
keyValue).stringValue());
}
}
}
}

JFreeChart chart = ChartFactory
.createBarChart3D(
element.getName(),
source.getProperty(BAR_CATEGORY_AXIS_LABEL),
source.getProperty(BAR_VALUE_AXIS_LABEL),
dataset,
(BAR_ORIENTATION_HORIZONTAL.equals(source
.getProperty(BAR_ORIENTATION))) ? PlotOrientation.HORIZONTAL
: PlotOrientation.VERTICAL, true, true, true);

GradientPaint gradientpaint0 = new GradientPaint(0.0F, 0.0F, new Color(
0, 0, 250), 0.0F, 0.0F, new Color(136, 136, 255));

BarRenderer3D r = (BarRenderer3D) chart.getCategoryPlot().getRenderer();
r.setSeriesPaint(0, gradientpaint0);

return chart;
}

@Override
public String getType() {
return "Bar";
}

}
@@ -0,0 +1,23 @@
package com.ramussoft.chart;

public interface ChartConstants {

public static final String PIE_ATTRIBUTE_KEY = "pie-attribute-key";

public static final String PIE_ATTRIBUTE_VALUE = "pie-attribute-value";

public static final String BAR_ATTRIBUTE_KEY = "bar-attribute-key";

public static final String BAR_ATTRIBUTE_VALUE_PREFIX = "bar-attribute-value-";

public static final String BAR_ORIENTATION = "bar-orientation";

public static final String BAR_ORIENTATION_VERTICAL = "bar-orientation-vertical";

public static final String BAR_ORIENTATION_HORIZONTAL = "bar-orientation-horizontal";

public static final String BAR_CATEGORY_AXIS_LABEL = "bar-category-axis-label";

public static final String BAR_VALUE_AXIS_LABEL = "bar-value-axis-label";

}
Oops, something went wrong.

0 comments on commit d827103

Please sign in to comment.
You can’t perform that action at this time.