Skip to content

Instantly share code, notes, and snippets.

View magomar's full-sized avatar
💭
Forever Learning

Mario Gómez Martínez magomar

💭
Forever Learning
View GitHub Profile
@magomar
magomar / CurrencyConverter.java
Last active August 29, 2015 14:15
Main class of the CurrencyConverterLite JavaFX app
package currencyconverter.app;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class CurrencyConverter extends Application {
@magomar
magomar / Currency.java
Last active August 29, 2015 14:15
Model of the CurrencyConverterLite JavaFX app
package currencyconverter.app;
public enum Currency {
USD("U.S. Dollar", 1.0),
GBP("British Pound", 1.56285),
EUR("Euro", 1.22293);
private double dollarConversionRate;
private String fullName;
@magomar
magomar / Controller.java
Last active August 29, 2015 14:15
Controller of the CurrencyConverterLite JavaFX app
package currencyconverter.app;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
@magomar
magomar / view.fxml
Created February 16, 2015 16:57
FXML View of the CurrencyConverterLite JavaFX app
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="currencyconverter.app.Controller">
<children>
@magomar
magomar / HexagonalMapGUI-0.0.2
Last active November 14, 2018 09:59
HexagonalMaps: HexagonalMapGUI
public class HexagonalMapGUI extends JFrame {
static final int MAP_WIDTH = 10; // number of columns
static final int MAP_HEIGHT = 10; // number of rows
static final TerrainType SOME_TERRAIN_TYPE = TerrainType.FOREST;
private HexagonalMap map;
private MapInfo info;
private JPanel mainPanel;
public HexagonalMapGUI() {
@magomar
magomar / HexagonalMap-0.0.2
Last active November 14, 2018 10:01
HexagonalMaps: HexagonalMap
public class HexagonalMap extends JPanel {
private int width; // Number of columns
private int height; // Number of rows
private int hexSide; // Side of the hexagon
private int hexOffset; // Distance from left horizontal vertex to vertical axis
private int hexApotheme; // Apotheme of the hexagon = radius of inscribed circumference
private int hexRectWidth; // Width of the circumscribed rectangle
private int hexRectHeight; // Height of the circumscribed rectangle
private int hexGridWidth; // hexOffset + hexSide (b + s)
private BufferedImage globalImage;
@magomar
magomar / Board
Last active November 14, 2018 10:34
HexagonalMaps: Board
public class Board {
private Tile[][] tiles;
private int width;
private int height;
private Board(int width, int height) {
this.width = width;
this.height = height;
}
@magomar
magomar / Directions
Last active November 14, 2018 09:58
HexagonalMaps: Directions
public enum Directions {
N,
NE,
N_NE,
SE,
N_SE,
NE_SE,
N_NE_SE,
S,
@magomar
magomar / Direction_0.0.2
Last active November 14, 2018 10:07
HexagonalMaps: Direction
public enum Direction {
N(0, -1, -1),
NE(1, 0, -1),
SE(1, 1, 0),
S(0, 1, 1),
SW(-1, 1, 0),
NW(-1, 0, -1),
C(0, 0, 0);
private final int incColumn;
private final int incRowEven;
@magomar
magomar / Tile
Last active November 14, 2018 10:19
HexagonalMaps: Tile
public class Tile {
private java.util.Map<TerrainType, Directions> terrain;
private Tile() {
this.terrain = new EnumMap<>(TerrainType.class);
}
public Map<TerrainType, Directions> getTerrain() {
return terrain;
}