Example usage for javafx.scene.paint Color RED

List of usage examples for javafx.scene.paint Color RED

Introduction

In this page you can find the example usage for javafx.scene.paint Color RED.

Prototype

Color RED

To view the source code for javafx.scene.paint Color RED.

Click Source Link

Document

The color red with an RGB value of #FF0000

Usage

From source file:ruleprunermt2.FXMLDocumentController.java

@FXML
protected void chooseFile(ActionEvent event) throws IOException {
    CSVdata = new ArrayList<>();
    File file = fileChooser.showOpenDialog(null);
    if (file.exists()) {
        if (file.getName().endsWith(".csv")) {
            fileName.setTextFill(Color.BLACK);
            fileName.setText(file.getName());
            String[] tmp = file.getName().split("\\.");
            nameOfTheChosenFile = tmp[0];
            File dir = new File(nameOfTheChosenFile);
            if (dir.exists()) {
                FileUtils.deleteDirectory(dir);
            }//from w  ww .  java  2s  . c  om
            dir.mkdir();

            CSVHandler.readCSV(CSVdata, file.getAbsolutePath(), label);

        } else {
            fileName.setTextFill(Color.RED);
            fileName.setText("Improper file format");
        }
    }
}

From source file:ruleprunermt2.FXMLDocumentController.java

@FXML
protected void chooseSeed(ActionEvent event) throws IOException {
    seedItems = new ArrayList<>();
    File file = seedFileChooser.showOpenDialog(null);
    if (file.exists()) {
        if (file.getName().endsWith(".txt")) {
            seedName.setTextFill(Color.BLACK);
            seedName.setText(file.getName());

            CSVHandler.readSeed(seedItems, file.getAbsolutePath());

        } else {//www .j a v a  2  s . c  om
            seedName.setTextFill(Color.RED);
            seedName.setText("Improper file format");
        }
    }
}

From source file:com.shootoff.config.Configuration.java

public Optional<Color> getIgnoreLaserColor() {
    if (ignoreLaserColorName.equals("red")) {
        return Optional.of(Color.RED);
    } else if (ignoreLaserColorName.equals("green")) {
        return Optional.of(Color.GREEN);
    }/*from  w  w  w. j  a va2  s  .  c o  m*/

    return Optional.empty();
}

From source file:ruleprunermt2.FXMLDocumentController.java

@FXML
protected void divideTVT(ActionEvent event) throws IOException {
    if (!CSVdata.isEmpty() && !seedItems.isEmpty()) {
        File dir1 = new File(nameOfTheChosenFile + "/train-validation-test1");
        File dir2 = new File(nameOfTheChosenFile + "/train-validation-test2");
        if (dir1.exists()) {
            FileUtils.deleteDirectory(dir1);
        }//from   ww w  .  j av a2  s .  c  o  m
        dir1.mkdir();

        if (dir2.exists()) {
            FileUtils.deleteDirectory(dir2);
        }
        dir2.mkdir();

        for (int iterator = 0; iterator < seedItems.size(); iterator++) {
            long seed = Integer.parseInt(seedItems.get(iterator));
            Collections.shuffle(CSVdata, new Random(seed));

            try (FileWriter writeTrain = new FileWriter(nameOfTheChosenFile + "/train-validation-test1/"
                    + nameOfTheChosenFile + "_" + (iterator + 1) + "train.csv")) {
                writeTrain.append(label[0] + "\n");
                writeTrain.append(label[1] + "\n");
                for (int i = 0; i < Math.floor((CSVdata.size() * 3) / 10); i++) {
                    writeTrain.append(CSVdata.get(i) + "\n");
                }
                writeTrain.close();
            }

            try (FileWriter writeValidation = new FileWriter(nameOfTheChosenFile + "/train-validation-test1/"
                    + nameOfTheChosenFile + "_" + (iterator + 1) + "validation.csv")) {
                writeValidation.append(label[0] + "\n");
                writeValidation.append(label[1] + "\n");
                for (int i = (int) Math.floor((CSVdata.size() * 3) / 10); i < Math
                        .floor(CSVdata.size() / 2); i++) {
                    writeValidation.append(CSVdata.get(i) + "\n");
                }
                writeValidation.close();
            }

            try (FileWriter writeTest = new FileWriter(nameOfTheChosenFile + "/train-validation-test1/"
                    + nameOfTheChosenFile + "_" + (iterator + 1) + "test.csv")) {
                writeTest.append(label[0] + "\n");
                writeTest.append(label[1] + "\n");
                for (int i = (int) Math.floor(CSVdata.size() / 2); i < CSVdata.size(); i++) {
                    writeTest.append(CSVdata.get(i) + "\n");
                }
                writeTest.close();

            }

            //Second division
            try (FileWriter writeTrain = new FileWriter(nameOfTheChosenFile + "/train-validation-test2/"
                    + nameOfTheChosenFile + "_" + (iterator + 1) + "test.csv")) {
                writeTrain.append(label[0] + "\n");
                writeTrain.append(label[1] + "\n");
                for (int i = 0; i < Math.floor((CSVdata.size()) / 2); i++) {
                    writeTrain.append(CSVdata.get(i) + "\n");
                }
                writeTrain.close();
            }

            try (FileWriter writeValidation = new FileWriter(nameOfTheChosenFile + "/train-validation-test2/"
                    + nameOfTheChosenFile + "_" + (iterator + 1) + "train.csv")) {
                writeValidation.append(label[0] + "\n");
                writeValidation.append(label[1] + "\n");
                for (int i = (int) Math.floor((CSVdata.size()) / 2); i < Math
                        .floor((CSVdata.size() * 8) / 10); i++) {
                    writeValidation.append(CSVdata.get(i) + "\n");
                }
                writeValidation.close();
            }

            try (FileWriter writeTest = new FileWriter(nameOfTheChosenFile + "/train-validation-test2/"
                    + nameOfTheChosenFile + "_" + (iterator + 1) + "validation.csv")) {
                writeTest.append(label[0] + "\n");
                writeTest.append(label[1] + "\n");
                for (int i = (int) Math.floor((CSVdata.size() * 8) / 10); i < CSVdata.size(); i++) {
                    writeTest.append(CSVdata.get(i) + "\n");
                }
                writeTest.close();

            }
        }
        ButtonType buttonOK = new ButtonType("OK", ButtonData.OK_DONE);
        Dialog<String> dialog = new Dialog<>();
        dialog.getDialogPane().getButtonTypes().add(buttonOK);
        dialog.setContentText("Division successful");
        dialog.showAndWait();

    }
    if (CSVdata.isEmpty()) {
        fileName.setTextFill(Color.RED);
        fileName.setText("Data file is empty");
    }
    if (seedItems.isEmpty()) {
        seedName.setTextFill(Color.RED);
        seedName.setText("Seed file is empty");
    }

}

From source file:org.nmrfx.processor.gui.spectra.DatasetAttributes.java

private void initialize(Dataset aFile, String fileName) {
    theFile = aFile;/*from  w  w w .ja v  a  2 s . c o m*/
    nDim = aFile.getNDim();
    setFileName(fileName);
    pt = new int[theFile.getNDim()][2];
    ptd = new double[theFile.getNDim()][2];
    iLim = new int[theFile.getNDim()][2];
    iSize = new int[theFile.getNDim()];
    iBlkSize = new int[theFile.getNDim()];
    iNBlks = new int[theFile.getNDim()];
    iVecGet = new int[theFile.getNDim()];
    iBlkGet = new int[theFile.getNDim()];
    iVecPut = new int[theFile.getNDim()];
    iBlkPut = new int[theFile.getNDim()];
    iWDim = new int[theFile.getNDim()];

    title = aFile.getTitle();
    int i;

    for (i = 0; i < theFile.getNDim(); i++) {
        pt[i][0] = 0;
        ptd[i][0] = 0;
        pt[i][1] = theFile.getSize(i) - 1;
        ptd[i][1] = theFile.getSize(i) - 1;
    }

    pt[0][0] = 0;
    pt[0][1] = theFile.getSize(0) - 1;

    if (theFile.getNDim() > 1) {
        pt[1][0] = 0;
        ptd[1][0] = 0;
        pt[1][1] = theFile.getSize(1) - 1;
        ptd[1][1] = theFile.getSize(1) - 1;
    }

    chunkSize = new int[theFile.getNDim()];
    chunkOffset = new int[theFile.getNDim()];
    dim = new int[theFile.getNDim()];

    for (i = 0; i < theFile.getNDim(); i++) {
        dim[i] = i;
        chunkSize[i] = 1;
    }

    if (theFile.getLvl() > 0) {
        setLvl(theFile.getLvl());
    }
    setPosColor(Color.valueOf(theFile.getPosColor()));
    setNegColor(Color.valueOf(theFile.getNegColor()));

    if ((theFile.getPosneg() & 2) == 2) {
        setNegColor(Color.RED);
        setNeg(true);
    }

    if ((theFile.getPosneg() & 1) != 1) {
        setPosColor(Color.BLACK);
        setPos(false);
    }
    hasLevel = false;
}

From source file:ruleprunermt2.FXMLDocumentController.java

@FXML
protected void kFoldCrossValidation(ActionEvent event) throws IOException {
    int tmp = (int) kSlider.getValue();
    if (!CSVdata.isEmpty() && !seedItems.isEmpty()) {
        //            File f = new File(fileName.getText() + "/train-validation-test/.");
        File dir = new File(nameOfTheChosenFile + "/k-fold symmetric cross validation");
        if (dir.exists()) {
            FileUtils.deleteDirectory(dir);
        }/*from  w w w  .  ja  va2 s . c om*/
        dir.mkdir();

        for (int iterator = 0; iterator < seedItems.size(); iterator++) {
            long seed = Integer.parseInt(seedItems.get(iterator));
            Collections.shuffle(CSVdata, new Random(seed));

            int size = (int) Math.ceil((double) CSVdata.size() / (double) tmp);
            for (int i = 0; i < tmp; i++) {

                try (FileWriter writeFile = new FileWriter(
                        nameOfTheChosenFile + "/k-fold symmetric cross validation/" + nameOfTheChosenFile + "_"
                                + (iterator + 1) + "_" + (i + 1) + ".csv")) {
                    int limit = 0;
                    int oldLimit = 0;
                    //                        if (tmp > 2) {
                    if (i < (tmp - 1)) {
                        limit = (i + 1) * size;
                    } else {
                        limit = CSVdata.size();
                    }
                    //                        } else if (tmp == 2) { // division 70train :  30test
                    //                            if (i == 0) {
                    //                                limit = (int) Math.ceil((double) 0.7 * CSVdata.size());
                    //                            } else {
                    //                                oldLimit = (int) Math.ceil((double) 0.7 * CSVdata.size());;
                    //                                limit = CSVdata.size();
                    //                            }
                    //                        }

                    writeFile.append(label[0] + "\n");
                    writeFile.append(label[1] + "\n");
                    //                        if (tmp > 2) {
                    for (int j = i * size; j < limit; j++) {
                        writeFile.append(CSVdata.get(j) + "\n");
                    }
                    //                        } else if (tmp == 2) { // division 70train :  30test
                    //                            for (int j = oldLimit; j < limit; j++) {
                    //                                writeFile.append(CSVdata.get(j) + "\n");
                    //                            }
                    //                        }
                    writeFile.close();
                }
            }
        }
        ButtonType buttonOK = new ButtonType("OK", ButtonData.OK_DONE);
        Dialog<String> dialog = new Dialog<>();
        dialog.getDialogPane().getButtonTypes().add(buttonOK);
        dialog.setContentText("Division successful");
        dialog.showAndWait();
    }
    if (CSVdata.isEmpty()) {
        fileName.setTextFill(Color.RED);
        fileName.setText("Data file is empty");
    }
    if (seedItems.isEmpty()) {
        seedName.setTextFill(Color.RED);
        seedName.setText("Seed file is empty");
    }

}

From source file:santandersensors_client.JFrame.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    JSONObject jsonStr = new JSONObject();
    String[] date = new String[2];
    Double[] loc = new Double[2];
    if (jRadioButton5.isSelected()) {
        jsonStr.put("tags", jComboBox4.getSelectedItem());
        jsonStr.put("name", jComboBox3.getSelectedItem());
        jsonStr.put("scelta", 1);
        jsonStr.put("cutValue", jSpinner1.getValue());
        jsonStr.put("id", jTextField1.getText());

    }/*from www  .ja v  a  2  s  .c om*/
    if (jRadioButton6.isSelected()) {
        jsonStr.put("tags", jComboBox4.getSelectedItem());
        jsonStr.put("name", jComboBox3.getSelectedItem());
        jsonStr.put("scelta", 2);
        jsonStr.put("cutValue", jSpinner1.getValue());
        jsonStr.put("id", jTextField1.getText());
        date[0] = jFormattedTextField1.getText();
        date[1] = jFormattedTextField2.getText();
        jsonStr.put("data", date);
    }
    if (jRadioButton7.isSelected()) {
        jsonStr.put("tags", jComboBox4.getSelectedItem());
        jsonStr.put("name", jComboBox3.getSelectedItem());
        jsonStr.put("scelta", 3);
        jsonStr.put("cutValue", jSpinner1.getValue());
        jsonStr.put("id", "");
        loc[0] = (Double) jSpinner2.getValue();
        loc[1] = (Double) jSpinner4.getValue();
        jsonStr.put("loc", loc);
        jsonStr.put("rad", jSpinner3.getValue());
    }
    if (jRadioButton8.isSelected()) {
        jsonStr.put("tags", jComboBox4.getSelectedItem());
        jsonStr.put("name", jComboBox3.getSelectedItem());
        jsonStr.put("scelta", 4);
        jsonStr.put("cutValue", jSpinner1.getValue());
        jsonStr.put("id", "");
        date[0] = jFormattedTextField1.getText();
        date[1] = jFormattedTextField2.getText();
        loc[0] = (Double) jSpinner2.getValue();
        loc[1] = (Double) jSpinner4.getValue();
        jsonStr.put("data", date);
        jsonStr.put("loc", loc);
        jsonStr.put("rad", jSpinner3.getValue());
    }
    if (jRadioButton1.isSelected()) {
        jsonStr.put("id", jTextField1.getText());
        jsonStr.put("scelta", 5);
        date[0] = jFormattedTextField1.getText();
        date[1] = jFormattedTextField2.getText();
        jsonStr.put("data", date);
    }

    output.println(jsonStr);
    jTextArea1.setForeground(java.awt.Color.RED);
    jTextArea1.setText("In attesa di risposta...");
}

From source file:org.dataconservancy.packaging.gui.presenter.impl.PackageGenerationPresenterImpl.java

private void setViewToDefaults() {
    if (generationParams.getParam(GeneralParameterNames.COMPRESSION_FORMAT) != null
            && !generationParams.getParam(GeneralParameterNames.COMPRESSION_FORMAT).isEmpty()) {
        for (Toggle compressionToggle : view.getCompressionToggleGroup().getToggles()) {
            if (compressionToggle.getUserData()
                    .equals(generationParams.getParam(GeneralParameterNames.COMPRESSION_FORMAT).get(0))) {
                compressionToggle.setSelected(true);
                break;
            }/*  ww  w.j  a v a  2s  . com*/
        }
    }

    if (generationParams.getParam(GeneralParameterNames.ARCHIVING_FORMAT) != null
            && !generationParams.getParam(GeneralParameterNames.ARCHIVING_FORMAT).isEmpty()) {
        for (Toggle archivingToggle : view.getArchiveToggleGroup().getToggles()) {
            if (archivingToggle.getUserData()
                    .equals(generationParams.getParam(GeneralParameterNames.ARCHIVING_FORMAT).get(0))) {
                archivingToggle.setSelected(true);
                break;
            }
        }
    }

    if (generationParams.getParam(BagItParameterNames.CONTACT_EMAIL) != null
            && !generationParams.getParam(BagItParameterNames.CONTACT_EMAIL).isEmpty()) {
        view.getContactEmailTextField()
                .setText(generationParams.getParam(BagItParameterNames.CONTACT_EMAIL).get(0));
    }

    if (generationParams.getParam(BagItParameterNames.CONTACT_NAME) != null
            && !generationParams.getParam(BagItParameterNames.CONTACT_NAME).isEmpty()) {
        view.getContactNameTextField().setText(generationParams.getParam(BagItParameterNames.CONTACT_NAME, 0));
    }

    if (generationParams.getParam(BagItParameterNames.CONTACT_PHONE) != null
            && !generationParams.getParam(BagItParameterNames.CONTACT_PHONE).isEmpty()) {
        view.getContactPhoneTextField()
                .setText(generationParams.getParam(BagItParameterNames.CONTACT_PHONE, 0));
    }

    if (generationParams.getParam(BagItParameterNames.EXTERNAL_IDENTIFIER) != null
            && !generationParams.getParam(BagItParameterNames.EXTERNAL_IDENTIFIER).isEmpty()) {
        view.getExternalIdentifierTextField()
                .setText(generationParams.getParam(BagItParameterNames.EXTERNAL_IDENTIFIER, 0));
    }

    if (generationParams.getParam(BagItParameterNames.CHECKSUM_ALGORITHMS) != null
            && !generationParams.getParam(BagItParameterNames.CHECKSUM_ALGORITHMS).isEmpty()) {
        for (String checksumParam : generationParams.getParam(BagItParameterNames.CHECKSUM_ALGORITHMS)) {
            if (checksumParam.equalsIgnoreCase("md5")) {
                view.getMd5CheckBox().setSelected(true);
            } else if (checksumParam.equalsIgnoreCase("sha1")) {
                view.getSHA1CheckBox().setSelected(true);
            }
        }

    }

    if (generationParams.getParam(GeneralParameterNames.PACKAGE_LOCATION) != null
            && !generationParams.getParam(GeneralParameterNames.PACKAGE_LOCATION).isEmpty()) {
        String filePath = generationParams.getParam(GeneralParameterNames.PACKAGE_LOCATION, 0);
        if (filePath != null && !filePath.isEmpty()) {
            File outputDirectory = new File(filePath);
            if (!outputDirectory.exists()) {
                if (!outputDirectory.mkdirs()) {
                    // If the directory could not be created, reset outputDirectory, and display a warning
                    controller.setOutputDirectory(null);
                    view.getStatusLabel().setText(errors.get(ErrorKey.OUTPUT_DIR_NOT_CREATED_ERROR));
                    view.getStatusLabel().setTextFill(Color.RED);
                    view.getStatusLabel().setVisible(true);
                } else {
                    controller.setOutputDirectory(outputDirectory);
                }
            }
        }
    }

    setOutputDirectory(false);
}

From source file:org.dataconservancy.packaging.gui.presenter.impl.PackageGenerationPresenterImpl.java

/**
 * Sets the output name of the file that will be saved based on the path of the output directory the package name,
 * and the archive format, and the compression format.
 *///from  w w w. j  av a2 s.  co m
private void setOutputDirectory(boolean overrideStatus) {
    String currentOutput = "";
    String errorText = "";
    boolean hasPackageName = (getPackageName() != null && !getPackageName().isEmpty());

    if (!hasPackageName || controller.getOutputDirectory() == null) {
        if (hasPackageName) {
            errorText = errors.get(ErrorKey.OUTPUT_DIRECTORY_MISSING);
        } else if (controller.getOutputDirectory() != null) {
            errorText = errors.get(ErrorKey.PACKAGE_NAME_MISSING);
        } else {
            errorText = errors.get(ErrorKey.OUTPUT_DIRECTORY_AND_PACKAGE_NAME_MISSING);
        }
    }

    if (StringUtils.containsAny(getPackageName(), controller.getPackageFilenameIllegalCharacters())) {
        errorText = errors.get(ErrorKey.PACKAGE_FILENAME_HAS_ILLEGAL_CHARACTERS) + "   "
                + controller.getPackageFilenameIllegalCharacters();
    }

    if (errorText.isEmpty()) {
        currentOutput = controller.getOutputDirectory().getAbsolutePath() + File.separator + getPackageName();

        if (view.getArchiveToggleGroup().getSelectedToggle() != null
                && !view.getArchiveToggleGroup().getSelectedToggle().getUserData().equals("exploded")) {
            currentOutput += "." + view.getArchiveToggleGroup().getSelectedToggle().getUserData();
        }

        if (view.getCompressionToggleGroup().getSelectedToggle() != null) {
            String compressionExtension = (String) view.getCompressionToggleGroup().getSelectedToggle()
                    .getUserData();
            if (!compressionExtension.isEmpty()) {
                currentOutput += "." + compressionExtension;
            }
        }

        view.getStatusLabel().setVisible(false);
        view.getContinueButton().setDisable(false);
    } else {
        if (overrideStatus || !view.getStatusLabel().isVisible()) {
            view.getStatusLabel().setText(errorText);
            view.getStatusLabel().setTextFill(Color.RED);
            view.getStatusLabel().setVisible(true);
        }
        view.getContinueButton().setDisable(true);
    }

    // Warning for long filenames, won't prevent you from continuing but may cause an error when you actually save
    // Mostly affects Windows machines
    if (currentOutput.length() > 259) {
        view.getStatusLabel().setText(messages.formatFilenameLengthWarning(currentOutput.length()));
        view.getStatusLabel().setTextFill(Color.RED);
        view.getStatusLabel().setVisible(true);
    }

    view.getCurrentOutputDirectoryTextField().setText(currentOutput);
}

From source file:ui.main.MainViewController.java

private synchronized void paintWarningInRecieve(Chat chat, String Warning, String time) {
    //this method draws the recievied text message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override/*from  w  w w .j  a  v a  2  s .c  o  m*/
        protected HBox call() throws Exception {

            VBox vbox = new VBox(); //to add text

            ImageView imageRec = new ImageView(chatterAvatar.getImage()); //image
            imageRec.setFitHeight(60);
            imageRec.setFitWidth(50);

            String strChatterName = chat.getParticipant(); //add name of the chatter with light color
            strChatterName = Character.toUpperCase(strChatterName.charAt(0))
                    + strChatterName.substring(1, strChatterName.indexOf("@"));
            Label chatterName = new Label(strChatterName);
            chatterName.setDisable(true);

            Label timeL = new Label(time);
            timeL.setDisable(true);
            timeL.setFont(new Font("Arial", 10));

            //chat message
            BubbledLabel bbl = new BubbledLabel();
            bbl.setText(Warning);
            bbl.setBackground(new Background(new BackgroundFill(Color.RED, null, null)));

            vbox.getChildren().addAll(chatterName, bbl, timeL);
            vbox.setAlignment(Pos.CENTER_RIGHT);
            HBox hbox = new HBox();
            bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER);
            hbox.getChildren().addAll(imageRec, vbox);
            return hbox;
        }
    };

    recievedMessages.setOnSucceeded(event -> {
        chatList.getChildren().add(recievedMessages.getValue());
        scrollPane.setVvalue(scrollPane.getHmax());
        scrollPane.setVvalue(scrollPane.getHmax());
    });

    if (chat.getParticipant().contains(currentChat.getParticipant())) {
        Thread t = new Thread(recievedMessages);
        t.start();
        try {
            t.join();
        } catch (InterruptedException ex) {
            Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }
        //t.setDaemon(true);

    }
}