Skip to content

lirfu/LirfuGraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LirfuGraph

An extensional library and a quick solution for data presentation and comparison in Java.

What can it do?

It has a built-in simple window builder for basic graph tiling.

The VerticalContainer accepts Rows and stacks them one under another.
The Row class represents a row of graphs stacking them from left to right.
The current graphs are, and should be scalable depending on the window size.

Graphs currenty supported:

  • BarGraph

    • Presenting each added name-value pair as a bar.
    • When the bar gets too slim, it turns into a LinearGraph.
  • LinearGraph

    • Adding a line connecting values as they are added.
    • Displaying the value of the first and the last added value.
  • DualLinearGraph

    • A LinearGraph with two simultaneous lines of different colors.
  • MultiLinearGraph

    • A LinearGraph with more simultaneous lines of different colors.
    • Configurable titles (accordingly colored).
  • DialGraph

    • Displaying a single angle on a circle.
  • ScatterGraph

    • Displaying a set of points on a 2D graph.
    • Simultaneous sets of points on the same graph.
    • Configurable titles (accordingly colored).
  • EmptySpace

    • An empty area for better organization

How to use it?

The long way:

The first thing you need is a VerticalContainer to hold the Rows:

VerticalContainer container = new VerticalContainer();

Now you can create and add rows to the container:

Row row = new Row();
container.addRow(row);

Next add some graphs to the row:

BarGraph graph = new BarGraph("Graph name");
row.addGraph(graph);

Now populate the graph with some data:

for(int i = 0; i <= 10; i++)
  graph.add("Value" + i, (i-5)(i-5));

Finally, build and show the window:

new Window(container, true, true);

The short way:

First build the graph:

DualLinearGraph graph = new DualLinearGraph("Graph name");
for(int i = 0; i <= 10; i++)
  graph.add((i-5), (i-5)(i-5));

Then build the container:

VerticalContainer container = new VerticalContainer();
container.addRow(new Row().addGraph(graph));

And finally, build and show the window:

new Window(container, true, true);

How to build your own graph? 🐜

Each graph extends the GraphTemplate, which contains following standardized values:

  • padding
  • interface color
  • primary graph color
  • secondary graph color (if a graph has two data sets)

It contains the getAdjustedSize method which returns your actual graph dimensions, subtracting the padding value.
The drawTitleAndFrame method should be called to draw the standardised graph frame and graph title.

The rest is up to you! 😄
All you need to implement is:

  • A method for adding data and a structure to store it
  • Override the paint(Graphics g) method and draw (present) the stored data
  • Get the graph location in window with getLocation() and correct drawing positions with it

Want to contribute?

If you like this project you're welcome to contribute with code or suggestions.
The project was created in IntelliJ IDEA 2016.1 (Community Edition).

Releases

No releases published

Packages

No packages published

Languages