Skip to content

Instantly share code, notes, and snippets.

Michael Heinrichs netopyr

Block or report user

Report or block netopyr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@netopyr
netopyr / cached_threads2.java
Created Mar 13, 2017
Example of a cached-thread-pool where all threads are daemon-threads
View cached_threads2.java
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
public class ImprovedCachedThreads {
public static void main(String[] args) {
final ThreadFactory threadFactory = runnable -> {
final Thread thread = new Thread(runnable, "HelloWorldThread");
thread.setDaemon(true);
@netopyr
netopyr / cached_threads1.java
Created Mar 13, 2017
Example where a cached-thread-pool prevents immediate exit of the application
View cached_threads1.java
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CachedThreads {
public static void main(String[] args) {
final ExecutorService executor = Executors.newCachedThreadPool();
executor.submit(() -> System.out.println("Hello World"));
}
@netopyr
netopyr / multi_stage_view.java
Created Feb 21, 2017
Example for multiple stages with ReduxFX
View multi_stage_view.java
public static VNode view(AppModel state) {
return Stages()
.children(
Stage()
.title("Left Screen")
.showing(state.getScreen() == Screen.LEFT)
.scene(
Scene()
.root(
StackPane()
@netopyr
netopyr / builder_api_0_2.java
Created Feb 21, 2017
Example of ReduxFX builder API 0.2
View builder_api_0_2.java
return HBox()
.padding(50.0)
.spacing(20.0)
.children(
ColorChooser()
.color(state.getColor(), (oldValue, newValue) -> Actions.updateColor(newValue)),
Region()
.background(state.getColor())
.minWidth(100.0)
.minHeight(100.0)
@netopyr
netopyr / builder_api_0_1.java
Created Feb 21, 2017
Example of ReduxFX builder API 0.1
View builder_api_0_1.java
return HBox(
padding(50.0),
spacing(20.0),
ColorChooser(
color(state.getColor(), (oldValue, newValue) -> Actions.updateColor(newValue))
),
Region(
background(state.getColor()),
minWidth(100.0),
minHeight(100.0)
@netopyr
netopyr / AppModel.java
Created Nov 3, 2016
Main state class of the ReduxFX sample project.
View AppModel.java
package com.netopyr.reduxfx.todo.state;
import javaslang.collection.Seq;
import org.apache.commons.lang3.builder.ToStringBuilder;
public final class AppModel {
private final String newTodoText;
private final Seq<TodoEntry> todos;
private final Filter filter;
@netopyr
netopyr / virtual_dom.js
Last active Oct 7, 2016
Virtual DOM example
View virtual_dom.js
{ tagName: 'div',
attributes: {
class: 'view'
},
children: [
{ tagName: 'input', ... },
{ tagName: 'label', ... },
{ tagName: 'button', ... }
]
}
View static_dummy.java
import com.netopyr.javafx.ik.Bone;
import com.netopyr.javafx.ik.Skeleton;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.stage.Stage;
public class Dummy extends Application {
@netopyr
netopyr / dummy1.java
Created Mar 28, 2013
Creating the structure of the dummy
View dummy1.java
// Definition of head
final Bone head = new Bone(30, 90);
// Definition of torso
final Bone torso = new Bone(80, 0);
head.getChildren().add(torso);
final Bone[] upperArm = new Bone[2];
final Bone[] upperLeg = new Bone[2];
@netopyr
netopyr / dummy2.java
Last active Dec 15, 2015
Attaching visual elements to the dummy
View dummy2.java
// Definition of head
final Bone head = new Bone(30, 90);
head.getContent().add(new Ellipse(20, 15));
// Definition of torso
final Bone torso = new Bone(80, 0);
torso.getContent().add(new Ellipse(40, 0, 50, 20));
head.getChildren().add(torso);
final Bone[] upperArm = new Bone[2];
You can’t perform that action at this time.