Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revision and update #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libraries/jsegue-0.0.3.jar"/>
<classpathentry kind="lib" path="libraries/reflections-0.9.11.jar"/>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jsegue</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
2 changes: 2 additions & 0 deletions .settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
9 changes: 9 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
42 changes: 2 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ A Java library of animated image-to-image transitions useful for slide shows, ph

| Animated Segue | Name | Description
|----------------|----------------|-------------------------------------
|![AlphaDissolveEffect](doc/images/AlphaDissolveEffect.gif) | `AlphaDissolveEffect` | Cross-dissolve from source to destination by increasing the source transparency while reducing the destination's.
|![Test](doc/images/1.gif) | `Test` | Test
|![Test](doc/images/2.gif) | `Test` | Test
|![PixelDissolveEffect](doc/images/PixelDissolveEffect.gif) | `PixelDissolveEffect` | Cross-dissolve from source to destination by randomly replacing source pixels with destination pixels.
|![CheckerboardEffect](doc/images/CheckerboardEffect.gif) | `CheckerboardEffect` | Destination image appears over the source in a 8x8 matrix.
|![BlindsEffect](doc/images/BlindsEffect.gif) | `BlindsEffect` | Destination appears in "louvered" horizontal stripes.
Expand Down Expand Up @@ -67,45 +68,6 @@ dependencies {
}
```

#### 2. Make your class react to animation changes:

As your animation runs, JSegue will notify you that a new animation frame is ready to be displayed. Typically you'll place this image into some component visible to the user:

```
public class MyClass implements SegueAnimationObserver {

private JLabel myDisplay;

...

@Override
void onFrameRendered(AnimatedSegue segue, BufferedImage image) {
myDisplay.setIcon(new ImageIcon(image));
}

}
```

#### 3. Build an animation:

```
BufferedImage mySource = ... ;
BufferedImage myDestination = ... ;

// Create a cross-dissolve segue
AnimatedSegue mySegue = SegueBuilder.of(BlindsEffect.class)
.withSource(mySource)
.withDestination(myDestination)
.withDuration(1500, TimeUnit.MILLISECONDS) // Animation lasts 1.5 seconds
.withMaxFramesPerSecond(30) // No more than 30fps
.withAnimationObserver(this) // Make this class an observer
.alphaBlend(true) // Overlay images; see FAQs
.build()

// Kick it off...
mySegue.start();

```

## Frequently Asked Questions

Expand Down
Binary file added doc/images/1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added libraries/jsegue-0.0.3.jar
Binary file not shown.
Binary file added libraries/reflections-0.9.11.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
</properties>

<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>javac2</artifactId>
Expand Down
149 changes: 149 additions & 0 deletions src/main/java/com/defano/jsegue/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package com.defano.jsegue;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import javax.imageio.ImageIO;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import com.defano.jsegue.renderers.ZoomInEffect;

@SuppressWarnings("all")

public class Main extends javax.swing.JFrame implements ActionListener, ChangeListener, SegueAnimationObserver {

private JLabel imagen = new JLabel();

public static void main(String[] args) throws IOException {
new Main();
}

public Main() throws IOException {

setTitle("Periquito v3 About");
setType(Type.UTILITY);
initComponents();

animar();

this.setVisible(true);

}

void animar() throws IOException {

BufferedImage mySource = getOrangeRect(200, 200);
BufferedImage myDestination = getBlueCircle(200, 200);

// Create a cross-dissolve segue
AnimatedSegue mySegue = SegueBuilder.of(ZoomInEffect.class).withSource(mySource).withDestination(myDestination)
.withDuration(1500, TimeUnit.MILLISECONDS) // Animation lasts 1.5 seconds
.withMaxFramesPerSecond(30) // No more than 30fps
.withAnimationObserver(this) // Make this class an observer
// Overlay images; see FAQs
.build();

// Kick it off...
mySegue.start();

}

public static BufferedImage getBlueCircle(int width, int height) {
BufferedImage src = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = src.createGraphics();
g.setPaint(new Color(10, 53, 150));
g.fillOval(0, 0, (int) (width * .75), (int) (height * .75));
g.dispose();

return src;
}

public static BufferedImage getOrangeRect(int width, int height) throws IOException {
Image img = ImageIO.read(new File("C:\\Users\\Yeah\\Desktop\\test.png"));
if (img instanceof BufferedImage) {
return (BufferedImage) img;
}

// Create a buffered image with transparency
BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

// Draw the image on to the buffered image
Graphics2D bGr = bimage.createGraphics();
bGr.drawImage(img, 0, 0, null);
bGr.dispose();

// Return the buffered image
return bimage;
}

private void initComponents() {

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setResizable(false);
imagen.setHorizontalAlignment(SwingConstants.CENTER);

imagen.addMouseListener(new MouseAdapter() {

@Override

public void mousePressed(MouseEvent e) {
try {
animar();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}

});

imagen.setIcon(new ImageIcon("C:\\Users\\Yeah\\Desktop\\test.png"));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup().addGap(34)
.addComponent(imagen, GroupLayout.PREFERRED_SIZE, 221, GroupLayout.PREFERRED_SIZE)
.addContainerGap(48, Short.MAX_VALUE)));
layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup().addGap(34)
.addComponent(imagen, GroupLayout.PREFERRED_SIZE, 219, GroupLayout.PREFERRED_SIZE)
.addContainerGap(23, Short.MAX_VALUE)));
getContentPane().setLayout(layout);
setSize(new Dimension(309, 305));
setLocationRelativeTo(null);
}

@Override
public void stateChanged(ChangeEvent e) {
// TODO Auto-generated method stub

}

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub

}

@Override
public void onFrameRendered(AnimatedSegue segue, BufferedImage image) {
imagen.setIcon(new ImageIcon(image));
}
}
27 changes: 27 additions & 0 deletions src/main/java/com/defano/jsegue/Segue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.defano.jsegue;

import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.reflections.Reflections;

public class Segue {

public static Set<Class<? extends AnimatedSegue>> classes() {
Reflections reflections = new Reflections("com.defano.jsegue.renderers");
return reflections.getSubTypesOf(AnimatedSegue.class).stream()
.filter(c -> !Modifier.isAbstract(c.getModifiers())).collect(Collectors.toSet());
}

public static List<String> names() {
return classes().stream().filter(c -> !Modifier.isAbstract(c.getModifiers())).map(Class::getSimpleName)
.collect(Collectors.toList());
}

public static Class<? extends AnimatedSegue> classNamed(String name) {
return classes().stream().filter(c -> c.getSimpleName().equalsIgnoreCase(name)).findFirst()
.orElseThrow(() -> new IllegalArgumentException("No such renderer: " + name));
}
}
Loading