2017-11-19 11:18:26 +00:00
|
|
|
package Classes.css.user;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import Classes.css.core.Context;
|
|
|
|
import Classes.css.core.Ruleset;
|
|
|
|
import javafx.scene.Node;
|
|
|
|
import javafx.scene.image.ImageView;
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
import javafx.scene.layout.HBox;
|
|
|
|
import javafx.scene.layout.Pane;
|
|
|
|
import javafx.scene.text.Text;
|
|
|
|
|
|
|
|
public class ArticleStylesheet{
|
|
|
|
|
|
|
|
/* Builds all necessary CSS/layout rules */
|
|
|
|
public ArticleStylesheet(Node target) throws Exception{
|
|
|
|
|
|
|
|
/* (1) Useful cast */
|
|
|
|
AnchorPane _target = (AnchorPane) target;
|
|
|
|
HBox _hc = (HBox) _target.getChildren().get(3);
|
|
|
|
|
|
|
|
/* (2) Set rules for parent */
|
|
|
|
Ruleset.load(_target)
|
|
|
|
|
|
|
|
.add("min-width", Context.getInt("article-width"))
|
|
|
|
.add("max-width", Context.getInt("article-width"))
|
|
|
|
|
|
|
|
.add("min-height", Context.getInt("article-height"))
|
2017-12-13 16:25:54 +00:00
|
|
|
// .add("max-height", Context.getInt("article-height"))
|
2017-11-19 11:18:26 +00:00
|
|
|
|
|
|
|
.add("pref-width", Context.getString("article-width"))
|
2017-12-13 16:25:54 +00:00
|
|
|
// .add("pref-height", Context.getString("article-height"))
|
2017-11-19 11:18:26 +00:00
|
|
|
|
|
|
|
// border
|
|
|
|
.add("border-insets", "10")
|
|
|
|
.add("border-radius", "3")
|
|
|
|
.add("border-color", "#ddd")
|
|
|
|
|
|
|
|
// bg
|
|
|
|
.add("background-radius", "3")
|
|
|
|
.add("background-color", "#fff")
|
|
|
|
.apply();
|
|
|
|
|
|
|
|
/* (2) Get children ruleset: picture, content, date, header_container */
|
|
|
|
this.Picture( (ImageView) _target.getChildren().get(0) ).apply();
|
|
|
|
this.Content( (Text) _target.getChildren().get(1) ).apply();
|
|
|
|
this.RelativeDate( (Text) _target.getChildren().get(2) ).apply();
|
|
|
|
this.HeaderContainer( (HBox) _target.getChildren().get(3) ).apply();
|
|
|
|
|
|
|
|
/* (3) Header container children: title, tag1, tag2, ... */
|
|
|
|
this.HeaderTitle( (Text) _hc.getChildren().get(0) ).apply();
|
|
|
|
|
|
|
|
for( int i = 0 ; i < _hc.getChildren().size()-1 ; i++ ){
|
|
|
|
|
|
|
|
Pane _tmp = (Pane) _hc.getChildren().get(i+1);
|
|
|
|
this.HeaderTag(_tmp).apply();
|
|
|
|
this.HeaderTextTag( (Text) _tmp.getChildren().get(0) ).apply();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Picture of article */
|
|
|
|
private Ruleset Picture(ImageView target) throws Exception{
|
|
|
|
|
|
|
|
return Ruleset.load(target)
|
|
|
|
.add("top", 20)
|
|
|
|
.add("left", 20)
|
|
|
|
.add("bottom", 20);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Article content */
|
|
|
|
private Ruleset Content(Text target) throws Exception{
|
|
|
|
|
|
|
|
return Ruleset.load(target)
|
|
|
|
.add("top", 50)
|
|
|
|
.add("left", 96)
|
|
|
|
.add("fill", "#808080")
|
|
|
|
.add("font-family", "Lato Regular")
|
|
|
|
.add("font-size", "12");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Header Container */
|
|
|
|
private Ruleset HeaderContainer(HBox target) throws Exception{
|
|
|
|
|
|
|
|
return Ruleset.load(target)
|
|
|
|
.add("top", 20)
|
|
|
|
.add("left", 96)
|
|
|
|
.add("pref-height", "21")
|
|
|
|
.add("pref-width", "200");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Relative date of article */
|
|
|
|
private Ruleset RelativeDate(Text target) throws Exception{
|
|
|
|
|
|
|
|
return Ruleset.load(target)
|
|
|
|
.add("top", 20)
|
|
|
|
.add("right", 20)
|
|
|
|
.add("fill", "#757575")
|
|
|
|
.add("font-family", "Lato Bold")
|
|
|
|
.add("font-size", "12");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Header Title */
|
|
|
|
private Ruleset HeaderTitle(Text target) throws Exception{
|
|
|
|
|
|
|
|
return Ruleset.load(target)
|
|
|
|
.add("font-family", "Lato Bold")
|
|
|
|
.add("font-size", "17");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Header Tag */
|
|
|
|
private Ruleset HeaderTag(Pane target) throws Exception{
|
|
|
|
|
|
|
|
return Ruleset.load(target)
|
|
|
|
.add("pref-width", 55)
|
|
|
|
.add("pref-height", 20)
|
|
|
|
.add("background-color", "#f8b02c")
|
|
|
|
.add("background-radius", "3");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Header Tag Text */
|
|
|
|
private Ruleset HeaderTextTag(Text target) throws Exception{
|
|
|
|
|
|
|
|
return Ruleset.load(target)
|
|
|
|
.add("fill", "#fff")
|
|
|
|
.add("font-family", "Lato Regular")
|
|
|
|
.add("font-size", "14");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|