106 lines
1.9 KiB
Java
106 lines
1.9 KiB
Java
package com.madeorsk.smartnotes.notes;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import com.madeorsk.smartnotes.NotesExplorer;
|
|
|
|
import javafx.scene.layout.VBox;
|
|
import javafx.scene.paint.Color;
|
|
|
|
public abstract class Note implements SavableNote
|
|
{
|
|
public enum NoteColor
|
|
{
|
|
WHITE(255, 255, 255),
|
|
BLUE(109, 140, 169),
|
|
YELLOW(212, 208, 97),
|
|
RED(214, 102, 90),
|
|
GREEN(100, 181, 106);
|
|
|
|
private double r;
|
|
private double g;
|
|
private double b;
|
|
|
|
NoteColor(double red, double green, double blue)
|
|
{
|
|
this.r = red;
|
|
this.g = green;
|
|
this.b = blue;
|
|
}
|
|
|
|
public Color getColor()
|
|
{
|
|
return new Color(this.r / 255, this.g / 255, this.b / 255, 1);
|
|
}
|
|
}
|
|
|
|
private String name;
|
|
private String textContent;
|
|
private NoteColor color = NoteColor.WHITE;
|
|
protected List<String> paths = new ArrayList<String>();
|
|
|
|
public void setName(String name)
|
|
{
|
|
this.name = name;
|
|
}
|
|
|
|
public String getName()
|
|
{
|
|
return this.name;
|
|
}
|
|
|
|
public void setNoteColor(NoteColor color)
|
|
{
|
|
this.color = color;
|
|
}
|
|
|
|
public NoteColor getNoteColor()
|
|
{
|
|
return this.color;
|
|
}
|
|
|
|
public List<String> getPaths()
|
|
{
|
|
return this.paths;
|
|
}
|
|
|
|
public void setTextContent(String content)
|
|
{
|
|
this.textContent = content;
|
|
this.updatePaths();
|
|
}
|
|
|
|
public String getTextContent()
|
|
{
|
|
return this.textContent;
|
|
}
|
|
|
|
private void updatePaths()
|
|
{
|
|
this.paths.clear();
|
|
String text = this.getTextContent();
|
|
if (text != null)
|
|
{
|
|
if (text.contains("\n"))
|
|
{
|
|
String[] lines = text.split("\n");
|
|
String lastLine = lines[lines.length - 1];
|
|
for (String word : lastLine.split(" "))
|
|
if (word.startsWith("#") && !word.equals("#"))
|
|
this.paths.add(word);
|
|
}
|
|
else
|
|
{
|
|
for (String word : text.split(" "))
|
|
if (word.startsWith("#") && !word.equals("#"))
|
|
this.paths.add(word);
|
|
}
|
|
}
|
|
}
|
|
|
|
public abstract VBox getViewBox(NotesExplorer explorer);
|
|
|
|
public abstract VBox getEditBox(NotesExplorer explorer);
|
|
}
|