merge
This commit is contained in:
commit
1f9d9086a6
|
@ -1,5 +1,25 @@
|
|||
package Classes;
|
||||
|
||||
public enum Category {
|
||||
business, entertainment, gaming, general, healthAndMedical, music, politics, scienceAndNature, sport, technology, all
|
||||
// business, entertainment, gaming, general, healthAndMedical, music, politics, scienceAndNature, sport, technology, all
|
||||
|
||||
all("all", "black"),
|
||||
business("business", "red"),
|
||||
entertainment("entertainment", "skyblue"),
|
||||
gaming("gaming", "green"),
|
||||
health("health", "yellow"),
|
||||
music("music", "purple"),
|
||||
sport("sport", "brown"),
|
||||
science("science", "#f14405"),
|
||||
nature("nature", "#16c668"),
|
||||
economics("economics", "#d1991b"),
|
||||
politics("politics", "#6825f4"),
|
||||
technology("technology", "#1e7ebe");
|
||||
|
||||
protected String color;
|
||||
protected String label;
|
||||
Category(String label, String color){ this.label = label; this.color = color; }
|
||||
|
||||
public String getLabel(){ return this.label; }
|
||||
public String getColor(){ return this.color; }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
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"))
|
||||
.add("max-height", Context.getInt("article-height"))
|
||||
|
||||
.add("pref-width", Context.getString("article-width"))
|
||||
.add("pref-height", Context.getString("article-height"))
|
||||
|
||||
// border
|
||||
.add("border-insets", "10")
|
||||
.add("border-radius", "3")
|
||||
.add("border-color", "#ddd")
|
||||
|
||||
// bg
|
||||
.add("background-insets", "10")
|
||||
.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");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,8 @@ public class ContextBuilder{
|
|||
Context.bind("header-height", 50);
|
||||
Context.bind("menu-width", 237);
|
||||
Context.bind("submenu-width", 200);
|
||||
Context.bind("article-width", 800);
|
||||
Context.bind("article-height", 96);
|
||||
|
||||
/* (3) Colors */
|
||||
Context.bind("main-color", 63, 81, 181);
|
||||
|
|
|
@ -12,7 +12,7 @@ public class SubMenuStyleSheet{
|
|||
/* (1) Set rules */
|
||||
Ruleset.load(target)
|
||||
.add("top", Context.getInt("header-height"))
|
||||
.add("left", Context.getInt("menu-width"))
|
||||
.add("left", Context.getInt("menu-width")-3)
|
||||
.add("bottom", 0)
|
||||
|
||||
.add("min-width", Context.getInt("submenu-width"))
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
package controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import Classes.Category;
|
||||
import Interfaces.EventObserver;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.text.Text;
|
||||
import model.NewsModel;
|
||||
|
||||
public class Article{
|
||||
|
||||
/* Data */
|
||||
private ArrayList<AnchorPane> items;
|
||||
private FlowPane parent;
|
||||
private EventObserver observer;
|
||||
|
||||
|
||||
/* Constructor */
|
||||
public Article(FlowPane p_parent, EventObserver observer){
|
||||
this.parent = p_parent;
|
||||
this.items = new ArrayList<AnchorPane>();
|
||||
this.observer = observer;
|
||||
}
|
||||
|
||||
public void addItem(NewsModel model) throws IOException {
|
||||
|
||||
/* (1) Load the article_disp.fxml */
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setLocation(getClass().getResource("/fxml/article_disp.fxml"));
|
||||
|
||||
/* (2) Get the loaded item*/
|
||||
AnchorPane item = (AnchorPane) loader.load();
|
||||
|
||||
/* (3) Set content */
|
||||
this.gsetContent( model.getDescription(), item );
|
||||
|
||||
/* (4) Set date */
|
||||
this.gsetDate( model.getDate(), item );
|
||||
|
||||
/* (5) Set title */
|
||||
HBox headerContainer = (HBox) item.getChildren().get(3);
|
||||
this.gsetTitle( model.getTitle(), headerContainer );
|
||||
|
||||
/* (6) Set tags */
|
||||
this.gsetTags( model.getTags(), headerContainer );
|
||||
|
||||
/* (7) Set image */
|
||||
this.gsetImage( model.getImageURL(), item );
|
||||
|
||||
/* (8) Bind event */
|
||||
// item.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||
// @Override
|
||||
// public void handle(MouseEvent event) {
|
||||
// Article.this.observer.handleEvent(new Classes.Event(item.getId(),"changeMainLayout"));
|
||||
// }
|
||||
// });
|
||||
|
||||
/* (9) Add to the controller local */
|
||||
this.items.add(item);
|
||||
|
||||
/* (10) On bind au width du parent */
|
||||
item.prefWidthProperty().bind(this.parent.widthProperty());
|
||||
item.maxWidthProperty().bind(this.parent.widthProperty());
|
||||
|
||||
/* (11) Add to parent (graphics) */
|
||||
Platform.runLater(new Runnable(){
|
||||
public void run(){
|
||||
Article.this.parent.getChildren().add(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void gsetContent(String p_content, AnchorPane p_parent){
|
||||
/* (1) Get node */
|
||||
Text g_content = (Text) p_parent.getChildren().get(1);
|
||||
|
||||
/* (2) Update content */
|
||||
g_content.setText(p_content);
|
||||
}
|
||||
|
||||
|
||||
public void gsetDate(Date p_date, AnchorPane p_parent){
|
||||
/* (1) Get node */
|
||||
Text g_date = (Text) p_parent.getChildren().get(2);
|
||||
|
||||
/* (2) Update content */
|
||||
g_date.setText(p_date.toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void gsetTitle(String p_title, HBox p_parent){
|
||||
/* (1) Get node */
|
||||
Text g_title = (Text) p_parent.getChildren().get(0);
|
||||
|
||||
/* (2) Update title */
|
||||
g_title.setText(p_title);
|
||||
}
|
||||
|
||||
|
||||
public void gsetImage(String p_uri, AnchorPane p_parent){
|
||||
/* (1) Get node */
|
||||
ImageView g_image = (ImageView) p_parent.getChildren().get(0);
|
||||
|
||||
/* (2) Update title */
|
||||
g_image.setImage(new Image(p_uri));
|
||||
}
|
||||
|
||||
|
||||
public void gsetTags(ArrayList<Category> p_tags, HBox p_parent) throws IOException{
|
||||
|
||||
/* (1) For each tag -> load a new one */
|
||||
for( Category tag : p_tags ){
|
||||
|
||||
/* (1.1) Create the container */
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setLocation(getClass().getResource("/fxml/article_tag_disp.fxml"));
|
||||
|
||||
/* (1.2) Load the tag elements */
|
||||
FlowPane g_tag = (FlowPane) loader.load();
|
||||
Text g_tagText = (Text) g_tag.getChildren().get(0);
|
||||
|
||||
/* (1.3) Update the tag name */
|
||||
g_tagText.setText(tag.getLabel());
|
||||
|
||||
/* (1.4) Set the custom color */
|
||||
g_tag.setStyle("-fx-background-color: "+tag.getColor());
|
||||
|
||||
/* (1.5) Ajout au parent*/
|
||||
p_parent.getChildren().add(g_tag);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -35,7 +35,7 @@ public class HeaderMenu{
|
|||
menuItem.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent event) {
|
||||
HeaderMenu.this.observer.handleEvent(new Classes.Event(menuItem.getId(),"changeMainLayout"));
|
||||
HeaderMenu.this.observer.handleEvent(new Classes.Event(menuItem.getId(), "changeMainLayout"));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,39 +1,37 @@
|
|||
package controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import Classes.ApiCall;
|
||||
import Classes.Category;
|
||||
import Classes.Languages;
|
||||
import Classes.SortTypes;
|
||||
import Classes.css.user.ContextBuilder;
|
||||
import Classes.css.user.HeaderStyleSheet;
|
||||
import Classes.css.user.HeaderIconStyleSheet;
|
||||
import Classes.css.user.HeaderStyleSheet;
|
||||
import Classes.css.user.MenuStyleSheet;
|
||||
import Classes.css.user.SubMenuStyleSheet;
|
||||
import Interfaces.Callback;
|
||||
import Interfaces.Event;
|
||||
import Interfaces.EventObserver;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.MenuBar;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import model.DictionaryModel;
|
||||
import model.LangModel;
|
||||
|
||||
import model.NewsListModel;
|
||||
import model.NewsModel;
|
||||
|
||||
public class RootLayout extends Application implements EventObserver {
|
||||
|
||||
private Stage root_stage;
|
||||
private Scene root_scene;
|
||||
private AnchorPane root_layout;
|
||||
|
||||
private FlowPane main_container;
|
||||
private Article articles;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -49,9 +47,12 @@ public class RootLayout extends Application implements EventObserver {
|
|||
/* (3) Load the CSS CONTEXT */
|
||||
ContextBuilder.createContext();
|
||||
|
||||
/* (3) Store container */
|
||||
this.main_container = (FlowPane) this.root_scene.lookup("#container");
|
||||
|
||||
|
||||
/* (1) HEADER
|
||||
|
||||
/* (1) Create controllers' views
|
||||
-------------------------------------*/
|
||||
/* (1) Create header menu */
|
||||
HeaderMenu hm = new HeaderMenu((FlowPane) this.root_scene.lookup("#header_menu"),this);
|
||||
|
@ -62,6 +63,10 @@ public class RootLayout extends Application implements EventObserver {
|
|||
hm.addItem("menu", "/src/header-menu.png");
|
||||
|
||||
|
||||
/* (2) Create container */
|
||||
this.articles = new Article(this.main_container, this);
|
||||
|
||||
|
||||
/* (2) CSS
|
||||
-------------------------------------*/
|
||||
|
||||
|
@ -134,17 +139,33 @@ public class RootLayout extends Application implements EventObserver {
|
|||
call.send();*/
|
||||
|
||||
switch(e.getEventType()){
|
||||
|
||||
case "changeMainLayout":
|
||||
this.handleMainLayoutChange(e.getObjectId());
|
||||
break;
|
||||
|
||||
case "NewsQuerySuccess":
|
||||
System.out.println(NewsListModel.getInstance().getNews().size()+" News ont été trouvé");
|
||||
if(NewsListModel.getInstance().getNews().size() != 0) {
|
||||
System.out.println("Le titre du premier article est: "+NewsListModel.getInstance().getNews().get(0).getTitle());
|
||||
System.out.println("La description du premier article est: "+NewsListModel.getInstance().getNews().get(0).getDescription());
|
||||
|
||||
// For each news
|
||||
for( NewsModel news : NewsListModel.getInstance().getNews() ){
|
||||
|
||||
try{
|
||||
|
||||
this.articles.addItem( news );
|
||||
|
||||
}catch(Exception e1){
|
||||
|
||||
System.out.println("Cannot fetch article data");
|
||||
e1.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "NewsQueryFailed":
|
||||
System.out.println("une erreur est survenue");
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane layoutX="65.0" layoutY="146.0" prefHeight="96.0" prefWidth="800.0" style="-fx-border-insets: 30; -fx-background-insets: 30; -fx-background-color: #fff; -fx-background-radius: 3; -fx-border-radius: 3; -fx-border-color: #ddd;">
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
<children>
|
||||
<ImageView fitHeight="56.0" fitWidth="56.0" layoutX="-28.0" layoutY="38.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="20.0">
|
||||
<image>
|
||||
<Image url="@../src/menu_profile_1.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<Text fill="#808080" fontSmoothingType="LCD" layoutX="118.0" layoutY="78.8439998626709" strokeType="OUTSIDE" strokeWidth="0.0" text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam posuere odio ut sem vestibulum, at tempus neque luctus. Curabitur quis tortor bibendum" wrappingWidth="653.0" AnchorPane.leftAnchor="96.0" AnchorPane.topAnchor="50.0">
|
||||
<font>
|
||||
<Font name="Lato Regular" size="12.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Text fill="#757575" layoutX="611.0" layoutY="37.0" strokeType="OUTSIDE" strokeWidth="0.0" text="10 days ago" textAlignment="RIGHT" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="20.0">
|
||||
<font>
|
||||
<Font name="Lato Bold" size="12.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<HBox layoutX="118.0" layoutY="39.0" prefHeight="21.0" prefWidth="200.0" AnchorPane.leftAnchor="96.0" AnchorPane.topAnchor="20.0">
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Some Article Title">
|
||||
<font>
|
||||
<Font name="Lato Bold" size="17.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<!-- <FlowPane alignment="CENTER" columnHalignment="CENTER" prefHeight="20.0" prefWidth="0.0" style="-fx-background-color: red; -fx-background-radius: 3;">
|
||||
<children>
|
||||
<Text fill="WHITE" fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="nature">
|
||||
<font>
|
||||
<Font name="Lato Regular" size="14.0" />
|
||||
</font>
|
||||
<FlowPane.margin>
|
||||
<Insets />
|
||||
</FlowPane.margin>
|
||||
</Text>
|
||||
</children>
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets left="5.0" right="5.0" />
|
||||
</padding>
|
||||
</FlowPane> -->
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
|
||||
<FlowPane alignment="CENTER" columnHalignment="CENTER" prefHeight="20.0" prefWidth="0.0" style="-fx-background-color: red; -fx-background-radius: 3;">
|
||||
<children>
|
||||
<Text fill="WHITE" fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="nature">
|
||||
<font>
|
||||
<Font name="Lato Regular" size="14.0" />
|
||||
</font>
|
||||
<FlowPane.margin>
|
||||
<Insets />
|
||||
</FlowPane.margin>
|
||||
</Text>
|
||||
</children>
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets left="5.0" right="5.0" />
|
||||
</padding>
|
||||
</FlowPane>
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
|
||||
<FlowPane alignment="CENTER_RIGHT" columnHalignment="RIGHT" layoutX="273.0" layoutY="-86.0" maxHeight="40.0" maxWidth="1240.0" orientation="VERTICAL" prefHeight="40.0" prefWrapLength="1240.0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Pane prefHeight="40.0" prefWidth="40.0" style="-fx-background-color: red; -fx-background-size: auto;">
|
||||
<FlowPane.margin>
|
||||
<Insets right="1.0" />
|
||||
</FlowPane.margin>
|
||||
</Pane>
|
||||
<Pane layoutX="10.0" layoutY="10.0" prefHeight="40.0" prefWidth="40.0" style="-fx-background-color: green;" />
|
||||
<Pane layoutX="10.0" layoutY="10.0" prefHeight="40.0" prefWidth="40.0" style="-fx-background-color: red; -fx-background-size: auto;" />
|
||||
</children>
|
||||
</FlowPane>
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.Cursor?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
@ -52,6 +54,63 @@
|
|||
</children>
|
||||
</AnchorPane>
|
||||
<VBox id="submenu" fx:id="submenu" layoutX="234.0" layoutY="50.0" prefHeight="650.0" prefWidth="194.0" style="-fx-background-color: white;" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="50.0" />
|
||||
<FlowPane id="container" fx:id="container" layoutX="421.0" layoutY="50.0" prefHeight="650.0" prefWidth="851.0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0" />
|
||||
<FlowPane id="container" fx:id="container" alignment="TOP_CENTER" columnHalignment="CENTER" layoutX="421.0" layoutY="50.0" prefWrapLength="1000.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="429.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0">
|
||||
<children>
|
||||
<AnchorPane fx:id="card1" prefHeight="118.0" style="-fx-border-insets: 10; -fx-background-insets: 10; -fx-background-color: #fff; -fx-background-radius: 3; -fx-border-radius: 3; -fx-border-color: #ddd;">
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
<children>
|
||||
<ImageView fitHeight="56.0" fitWidth="56.0" layoutX="-28.0" layoutY="38.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="20.0">
|
||||
<image>
|
||||
<Image url="@../src/menu_profile_1.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<Text fill="#808080" fontSmoothingType="LCD" layoutX="118.0" layoutY="78.8439998626709" strokeType="OUTSIDE" strokeWidth="0.0" text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam posuere odio ut sem vestibulum, at tempus neque luctus. Curabitur quis tortor bibendum" wrappingWidth="653.0" AnchorPane.leftAnchor="96.0" AnchorPane.topAnchor="50.0">
|
||||
<font>
|
||||
<Font name="Lato Regular" size="12.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Text fill="#757575" layoutX="611.0" layoutY="37.0" strokeType="OUTSIDE" strokeWidth="0.0" text="10 days ago" textAlignment="RIGHT" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="20.0">
|
||||
<font>
|
||||
<Font name="Lato Bold" size="12.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<HBox layoutX="118.0" layoutY="39.0" prefHeight="21.0" prefWidth="200.0" AnchorPane.leftAnchor="96.0" AnchorPane.topAnchor="20.0">
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Some Article Title">
|
||||
<font>
|
||||
<Font name="Lato Bold" size="17.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<FlowPane alignment="CENTER" columnHalignment="CENTER" prefHeight="20.0" style="-fx-background-color: red; -fx-background-radius: 3;">
|
||||
<children>
|
||||
<Text fill="WHITE" fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="nature">
|
||||
<font>
|
||||
<Font name="Lato Regular" size="14.0" />
|
||||
</font>
|
||||
<FlowPane.margin>
|
||||
<Insets />
|
||||
</FlowPane.margin>
|
||||
</Text>
|
||||
</children>
|
||||
<HBox.margin>
|
||||
<Insets left="10.0" />
|
||||
</HBox.margin>
|
||||
<padding>
|
||||
<Insets left="5.0" right="5.0" />
|
||||
</padding>
|
||||
</FlowPane>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<cursor>
|
||||
<Cursor fx:constant="HAND" />
|
||||
</cursor>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets></FlowPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<AnchorPane maxHeight="40.0" maxWidth="1280.0" prefHeight="40.0" prefWidth="1280.0" style="-fx-background-color: #3f51b5;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Pane layoutX="100.0" layoutY="-27.0" maxHeight="40.0" maxWidth="40.0" prefHeight="40.0" prefWidth="40.0" style="-fx-background-color: #3240a3;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
|
@ -158,12 +158,14 @@ public class NewsListModel implements Observable{
|
|||
for(int i = 0;i<arr.length();i++) {
|
||||
JSONObject jsonNews = (JSONObject)arr.get(i);
|
||||
NewsModel news = new NewsModel();
|
||||
|
||||
news.setAuthor(jsonNews.getString("author"))
|
||||
.setDescription(jsonNews.getString("description"))
|
||||
.setTitle(jsonNews.getString("title"))
|
||||
.setNewsURL(jsonNews.getString("url"))
|
||||
.setImageURL(jsonNews.getString("urlToImage"))
|
||||
.setSource(jsonNews.getJSONObject("source").getString("name"));
|
||||
.setSource(jsonNews.getJSONObject("source").getString("name"))
|
||||
.addTag(NewsListModel.this.cat);
|
||||
|
||||
try {
|
||||
news.setDate(jsonNews.getString("publishedAt"));
|
||||
|
|
|
@ -3,8 +3,11 @@ package model;
|
|||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import Classes.Category;
|
||||
|
||||
public class NewsModel {
|
||||
|
||||
private String author;
|
||||
|
@ -13,8 +16,16 @@ public class NewsModel {
|
|||
private String newsURL;
|
||||
private String title;
|
||||
private String description;
|
||||
private ArrayList<Category> tags;
|
||||
private Date date;
|
||||
|
||||
public NewsModel(){
|
||||
this.tags = new ArrayList<Category>();
|
||||
}
|
||||
public NewsModel addTag(Category tag) {
|
||||
this.tags.add(tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
|
@ -40,6 +51,9 @@ public class NewsModel {
|
|||
public String getNewsURL() {
|
||||
return newsURL;
|
||||
}
|
||||
public ArrayList<Category> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public NewsModel setNewsURL(String newsURL) {
|
||||
this.newsURL = newsURL;
|
||||
return this;
|
||||
|
|
Loading…
Reference in New Issue