Skip to content

Commit

Permalink
Public Release commit V1.0
Browse files Browse the repository at this point in the history
+ Color input / output links (No nodes use these yet, but the plan will
be for these to control gradient colors
+ Added css styling to the code with a default skin. New skins planned
with different colour schemes in future
+Added proper file save / load dialogue

~Fixed a ton of bugs, and made the core node functionality feel way
nicer (this took the most work :P)
  • Loading branch information
tiggerbiggo committed Oct 10, 2018
1 parent 2c39052 commit 1b6ef11
Show file tree
Hide file tree
Showing 57 changed files with 660 additions and 287 deletions.
1 change: 1 addition & 0 deletions PrimaPlay/PrimaPlay.iml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="lib" level="project" />
<orderEntry type="module" module-name="PrimaUtils" />
<orderEntry type="library" name="Maven: com.github.tiggerbiggo:loki:d09238dfeb" level="project" />
</component>
</module>
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.tiggerbiggo.prima.primaplay.core;

import com.tiggerbiggo.prima.primaplay.graphics.ImageTools;
import com.tiggerbiggo.prima.primaplay.graphics.SafeImage;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import javax.imageio.ImageIO;
import javax.imageio.stream.FileImageOutputStream;
import javax.imageio.stream.ImageOutputStream;
Expand Down Expand Up @@ -173,6 +176,42 @@ public static SafeImage safeGetImg(String filepath){
return new SafeImage(1, 1);
}
}

private static final FileChooser fileChooser = new FileChooser();

public static File showOpenDialogue() throws IOException {
return showOpenDialogue(null);
}

public static File showOpenDialogue(Stage stage) throws IOException {
new File("saves/").createNewFile();
fileChooser.getExtensionFilters().clear();
fileChooser.getExtensionFilters().add(new ExtensionFilter("Prima layout file", "*.prim"));
fileChooser.setTitle("Load");
fileChooser.setInitialDirectory(new File("saves/"));
File file = fileChooser.showOpenDialog(stage);
if(file != null){
return file;
}
throw new FileNotFoundException("User cancelled input, or file path invalid.");
}

public static File showSaveDialogue() throws IOException{
return showSaveDialogue(null);
}

public static File showSaveDialogue(Stage stage) throws IOException {
new File("saves/").createNewFile();
fileChooser.getExtensionFilters().clear();
fileChooser.getExtensionFilters().add(new ExtensionFilter("Prima layout file", "*.prim"));
fileChooser.setTitle("Save");
fileChooser.setInitialDirectory(new File("saves/"));
File file = fileChooser.showSaveDialog(stage);
if (file != null) {
return file;
}
throw new FileNotFoundException("User cancelled input, or file path invalid.");
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.tiggerbiggo.prima.primaplay.core;

import com.tiggerbiggo.prima.primaplay.graphics.ImageTools;
import com.tiggerbiggo.prima.primaplay.graphics.SafeImage;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.graphics.SimpleGradient;
import com.tiggerbiggo.prima.primaplay.node.core.INodeHasInput;
import com.tiggerbiggo.prima.primaplay.node.core.INodeHasOutput;
import com.tiggerbiggo.prima.primaplay.node.implemented.BasicRenderNode;
import com.tiggerbiggo.prima.primaplay.node.implemented.MapGenNode;
import com.tiggerbiggo.prima.primaplay.node.implemented.io.AnimationNode;
import com.tiggerbiggo.prima.primaplay.node.implemented.io.GradientNode;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.awt.Color;

public class Main {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

public class RenderParams {

private int width, height, x, y, n;
private int width, height, x, y, frameNum;

public RenderParams(int width, int height, int x, int y, int n) {
public RenderParams(int width, int height, int x, int y, int frameNum) {
this.width = width;
this.height = height;
this.x = x;
this.y = y;
this.n = n;
this.frameNum = frameNum;
}

public int width() {
Expand All @@ -29,7 +29,7 @@ public int y() {
}

public int frameNum() {
return n;
return frameNum;
}

public void setWidth(int width) {
Expand All @@ -48,12 +48,12 @@ public void setY(int y) {
this.y = y;
}

public void setN(int n) {
this.n = n;
public void setFrameNum(int frameNum) {
this.frameNum = frameNum;
}

@Override
public RenderParams clone() {
return new RenderParams(width, height, x, y, n);
return new RenderParams(width, height, x, y, frameNum);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.tiggerbiggo.utils.calculation.Calculation;
import java.awt.Color;
import java.util.function.Function;

/**
* Contains various static methods for calculating things like Hue, Saturation, Brightness, etc.
Expand Down Expand Up @@ -150,6 +149,23 @@ public static Color multiply(Color in, double toMul){
Math.min(255, Math.max((int)(in.getBlue() * toMul), 0))
);
}

/**Generates an array of Color.BLACK with length n
*
* @param n
* @return
* @throws ArrayIndexOutOfBoundsException if n < 0
*/
public static Color[] blankArray(int n) throws ArrayIndexOutOfBoundsException{
if(n < 0){
throw new ArrayIndexOutOfBoundsException("Error in ColorTools.blankArray: Number given was < 0, n: " + n);
}
Color[] toReturn = new Color[n];
for (int i=0 ;i<n; i++){
toReturn[i] = Color.BLACK;
}
return toReturn;
}
}


Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.tiggerbiggo.prima.primaplay.graphics;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.utils.calculation.Calculation;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.awt.Color;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.tiggerbiggo.prima.primaplay.node.implemented;

import com.tiggerbiggo.prima.primaplay.core.NewRenderer;
import com.tiggerbiggo.prima.primaplay.node.core.NodeHasInput;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.core.Renderer;
import com.tiggerbiggo.prima.primaplay.graphics.ColorTools;
import com.tiggerbiggo.prima.primaplay.node.core.NodeHasInput;
import com.tiggerbiggo.prima.primaplay.node.link.type.ColorArrayInputLink;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.util.concurrent.Future;

Expand All @@ -12,7 +15,12 @@ public class BasicRenderNode extends NodeHasInput{
private ColorArrayInputLink inputLink;

public BasicRenderNode(){
inputLink = new ColorArrayInputLink();
inputLink = new ColorArrayInputLink() {
@Override
public Color[] defaultValue(RenderParams p) {
return ColorTools.blankArray(p.frameNum());
}
};
addInput(inputLink);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tiggerbiggo.prima.primaplay.node.implemented;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.node.core.INodeHasOutput;
import com.tiggerbiggo.prima.primaplay.node.link.OutputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;

public class ConstNode implements INodeHasOutput {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tiggerbiggo.prima.primaplay.node.implemented;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.node.core.INodeHasOutput;
import com.tiggerbiggo.prima.primaplay.node.link.OutputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;

public class MapGenNode implements INodeHasOutput {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io;

import com.tiggerbiggo.utils.calculation.Calculation;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorArrayOutputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorInputLink;
import com.tiggerbiggo.utils.calculation.Calculation;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.util.function.Function;

public class AnimationNode extends NodeInOut {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.node.core.INodeHasOutput;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorInputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.util.function.BiFunction;

public class CombineNode extends NodeInOut {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io;

import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorArrayOutputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorInputLink;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.util.function.Function;

public class DualAnimateNode extends NodeInOut {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.graphics.Gradient;
import com.tiggerbiggo.prima.primaplay.graphics.HueCycleGradient;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.prima.primaplay.node.link.type.ColorArrayOutputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorArrayInputLink;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.awt.Color;

public class GradientNode extends NodeInOut {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import ch.hephaistos.utilities.loki.util.interfaces.ChangeListener;
import com.tiggerbiggo.prima.primaplay.core.FileManager;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.graphics.ColorConvertType;
import com.tiggerbiggo.prima.primaplay.graphics.SafeImage;
Expand All @@ -12,7 +10,6 @@
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.awt.Color;
import java.lang.reflect.Field;

public class ImageConvertNode extends NodeInOut{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.prima.primaplay.graphics.ColorConvertType;
import com.tiggerbiggo.prima.primaplay.node.link.type.ImageArrayInputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorArrayOutputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.graphics.ColorConvertType;
import com.tiggerbiggo.prima.primaplay.graphics.ColorTools;
import com.tiggerbiggo.prima.primaplay.graphics.ImageTools;
import com.tiggerbiggo.prima.primaplay.graphics.SafeImage;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.prima.primaplay.node.implemented.NodeFactory;
import com.tiggerbiggo.prima.primaplay.node.link.type.ColorArrayOutputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.ImageArrayInputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorArrayInputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorArrayOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.List;

public class ImageListNode extends NodeInOut{
@TransferGrid
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorInputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;

public class KaliedoNode extends NodeInOut {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorInputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;
import java.util.function.BiFunction;

public class TransformNode extends NodeInOut {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io.iterative;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.prima.primaplay.node.core.NodeInOut;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorInputLink;
import com.tiggerbiggo.prima.primaplay.node.link.type.VectorOutputLink;
import com.tiggerbiggo.utils.calculation.Vector2;

public abstract class IterativeNode extends NodeInOut {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.tiggerbiggo.prima.primaplay.node.implemented.io.iterative;

import ch.hephaistos.utilities.loki.util.annotations.TransferGrid;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;
import com.tiggerbiggo.utils.calculation.ComplexNumber;
import com.tiggerbiggo.utils.calculation.Vector2;
import com.tiggerbiggo.prima.primaplay.core.RenderParams;

public class MandelNode extends IterativeNode {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public String getDescription() {
}

@Override
public void onObjectValueChanged(Field field, Object o) {
public void onObjectValueChanged(Field field, Object oldValue, Object newValue, Object o) {
if(field.equals(f_filename)){
img = FileManager.safeGetImg(filename);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public String getDescription() {
}

@Override
public void onObjectValueChanged(Field field, Object o) {
public void onObjectValueChanged(Field field, Object oldValue, Object newValue, Object o) {
if(field.equals(f_filename)){
imgs = ImageTools.toSafeImage(FileManager.getImgsFromFolder(filename, true));
}
Expand Down
Loading

0 comments on commit 1b6ef11

Please sign in to comment.