Ejemplo n.º 1
0
  /** Create the tabbed panels for the GUI */
  private void createTabs() {

    // Create the tabbed pane
    mainPanel = new JTabbedPane(JTabbedPane.BOTTOM);

    // Create the various panels
    workspacePanel = new JPanel(new BorderLayout());
    userListPanel = new JPanel(new BorderLayout());
    searchPanel = new JPanel(new GridLayout(0, 2));

    // Create the pieces of the workspace panel
    workspaceList.setLayoutOrientation(JList.VERTICAL_WRAP);
    workspacePanel.add(new JScrollPane(workspaceList));
    workspacePanel.add(new JLabel("Local File Listing"), BorderLayout.NORTH);

    // Create the UserList tab
    JPanel labelPanel = new JPanel(new GridLayout(0, 2));
    labelPanel.add(new JLabel("Users Connected:"));
    labelPanel.add(new JLabel("Selected User's Files:"));

    JPanel listPanel = new JPanel(new GridLayout(0, 2));
    listPanel.add(new JScrollPane(userList));
    listPanel.add(new JScrollPane(fileList));

    userList.addMouseListener(mouseHandler);
    fileList.addMouseListener(mouseHandler);

    userListPanel.add(labelPanel, BorderLayout.NORTH);
    userListPanel.add(listPanel, BorderLayout.CENTER);

    // Create Search Panel
    searchPanel = new JPanel(new BorderLayout());
    JPanel searchOpsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    searchName = new JTextField(20);
    searchInit = new JButton("Search");
    searchInit.addMouseListener(mouseHandler);
    String types[] = {"Image", "Video", "Audio", "Any"};
    searchType = new JComboBox(types);
    searchType.setSelectedIndex(3);

    searchOpsPanel.add(new JLabel("Search String"));
    searchOpsPanel.add(searchName);
    searchOpsPanel.add(new JLabel("File Type"));
    searchOpsPanel.add(searchType);
    searchOpsPanel.add(searchInit);

    searchPanel.add(new JScrollPane(searchList));
    searchPanel.add(searchOpsPanel, BorderLayout.NORTH);

    // Add panels to the tab pane
    mainPanel.addTab("Home", workspacePanel);
    mainPanel.addTab("Server", userListPanel);
    mainPanel.addTab("Search", searchPanel);
  }
Ejemplo n.º 2
0
  GroupEditor() {
    setOpaque(true);
    setBorder(BorderFactory.createTitledBorder(messages.getString("buh.title.groupEditor")));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setPreferredSize(new Dimension(WIDTH, 0));

    categories = new JList(new CategoriesModel());
    categories.setLayoutOrientation(JList.VERTICAL);

    add(new JScrollPane(categories));
  }
Ejemplo n.º 3
0
  /** Constructor. */
  public TilePatternsView() {
    super();

    tilePatternIcons = new ArrayList<TilePatternIcon>();

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    // tileset properties
    // the tile pattern list
    // view of the current tile pattern

    // tileset properties
    tilesetPropertiesView = new TilesetPropertiesView();
    tilesetPropertiesView.setMaximumSize(new Dimension(Integer.MAX_VALUE, 120));
    tilesetPropertiesView.setAlignmentX(Component.LEFT_ALIGNMENT);

    // list
    tilePatternsListModel = new TilePatternsListModel();
    tilePatternsList = new JList(tilePatternsListModel);
    tilePatternsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tilePatternsList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    tilePatternsList.setVisibleRowCount(-1); // make the rows as wide as possible
    tilePatternsList
        .getSelectionModel()
        .addListSelectionListener(new TilePatternListSelectionListener());
    tilePatternsList.setCellRenderer(new TilePatternListRenderer());

    tilePatternsList.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_DELETE) {
              if (tileset != null && tileset.getSelectedTilePattern() != null) {
                tileset.removeTilePattern();
              }
            }
          }
        });

    JScrollPane listScroller = new JScrollPane(tilePatternsList);
    listScroller.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    listScroller.setAlignmentX(Component.LEFT_ALIGNMENT);

    // tile view
    tilePatternView = new TilePatternView();
    tilePatternView.setMaximumSize(new Dimension(Integer.MAX_VALUE, 300));
    tilePatternView.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(tilesetPropertiesView);
    add(Box.createRigidArea(new Dimension(0, 5)));
    add(listScroller);
    add(Box.createRigidArea(new Dimension(0, 5)));
    add(tilePatternView);
  }
  public BizSimMain(int numThreads, int numAgents, int numGenerations) {

    // configure our main window which will contain all the other elements
    JFrame control_window = new JFrame();
    control_window.setTitle("Control Suite");
    control_window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    control_window.setSize(new Dimension(800, 480));
    // control_window.setAlwaysOnTop(true);
    control_window.setLayout(new BorderLayout());

    JPanel species_control = new JPanel();
    JLabel species_list_l = new JLabel("Species Running");
    DefaultListModel species_list = new DefaultListModel();

    // create our Environment
    Environment e = new Environment();

    // create all our threads
    for (int kittehsex = 0; kittehsex < numThreads; ++kittehsex) {

      // create some test agents
      ArrayList<Agent> agents = new ArrayList<Agent>();
      for (int i = 0; i < numAgents; ++i) {
        agents.add(new Agent());
      }

      // create our new thread and pass in some control variables
      ProcessSimulator ps = new ProcessSimulator(agents, numGenerations, kittehsex, e, this);
      Thread t = new Thread(ps);
      species.add(ps);

      // update our current species list
      species_list.addElement("Species #" + kittehsex);

      // set the thread to a high priority, and then start it
      t.setPriority(9);
      t.start();
    }

    // create a selectable list of all the different species we have
    JList species_select_list = new JList(species_list);
    species_select_list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    species_select_list.setLayoutOrientation(JList.VERTICAL);
    species_select_list.setVisibleRowCount(3);

    // start listening to all buttons
    start_stop.addActionListener(this);
    reset.addActionListener(this);
    reconfigure.addActionListener(this);

    // add mnemonics to some buttons
    start_stop.setMnemonic('s');
    reset.setMnemonic('r');
    reconfigure.setMnemonic('e');

    // create a panel for all our environment variables
    JPanel environment_controls = new JPanel();
    environment_controls.setBorder(BorderFactory.createTitledBorder("Modify Finished Good Values"));
    environment_controls.setLayout(new GridLayout(3, 4));
    environment_controls.add(new JLabel("High Rate:"));
    environment_controls.add(high_rate);
    environment_controls.add(new JLabel("High Sale:"));
    environment_controls.add(high_sale);
    environment_controls.add(new JLabel("Med Rate:"));
    environment_controls.add(med_rate);
    environment_controls.add(new JLabel("Med Sale:"));
    environment_controls.add(med_sale);
    environment_controls.add(new JLabel("Low Rate:"));
    environment_controls.add(low_rate);
    environment_controls.add(new JLabel("Low Sale:"));
    environment_controls.add(low_sale);

    // create a panel for all our simulation variables
    JPanel simulation_controls = new JPanel();
    simulation_controls.setBorder(BorderFactory.createTitledBorder("Modify Simulation Controls"));
    simulation_controls.setLayout(new GridLayout(6, 2));
    simulation_controls.add(new JLabel("Agent Count:"));
    simulation_controls.add(agent_count);
    simulation_controls.add(new JLabel("Generation Count:"));
    simulation_controls.add(generation_count);
    simulation_controls.add(new JLabel("Elite Percent"));
    simulation_controls.add(elite_percent);
    simulation_controls.add(new JLabel("Parent Percent"));
    simulation_controls.add(parent_percent);
    simulation_controls.add(new JLabel("Agent Performance"));
    simulation_controls.add(agent_performance);

    // create a panel for displaying information about the current elite
    // agent
    JPanel elite_panel = new JPanel();
    elite_panel.setBorder(BorderFactory.createTitledBorder("Current Elite Agent Performance"));
    elite_panel.setLayout(new GridLayout(2, 2));
    elite_panel.add(new JLabel("Total: "));
    elite_panel.add(cur_elite_total);
    elite_panel.add(new JLabel("Genome: "));
    JScrollPane genome_scroll = new JScrollPane(cur_elite_genome);
    elite_panel.add(genome_scroll);

    // this panel encompasses the different panels for altering and showing
    // the current state of the simulation
    JPanel field_controls = new JPanel();
    field_controls.setLayout(new GridLayout(2, 2));
    field_controls.add(environment_controls);
    field_controls.add(simulation_controls);
    field_controls.add(elite_panel);

    // set some attributes on misc. GUI stuff
    cur_elite_genome.setWrapStyleWord(true);
    cur_elite_genome.setEditable(false);
    cur_elite_genome.setLineWrap(true);

    // set the size of the button to just 3 characters
    high_rate.setColumns(3);
    high_sale.setColumns(3);
    med_rate.setColumns(3);
    med_sale.setColumns(3);
    low_rate.setColumns(3);
    low_sale.setColumns(3);

    // set the current value of our fields to the current environment value
    high_rate.setText(e.getHQRate() + "");
    high_sale.setText(e.getHQSale() + "");
    med_rate.setText(e.getMQRate() + "");
    med_sale.setText(e.getMQSale() + "");
    low_rate.setText(e.getLQRate() + "");
    low_sale.setText(e.getLQSale() + "");

    // set the default value of our fields to the current simulation values
    day_count.setText("100");
    generation_count.setText(numGenerations + "");
    elite_percent.setText(".05");
    parent_percent.setText(".8");
    agent_count.setText(numAgents + "");
    agent_performance.setText(e.getIncomeRatioThreshold() + "");

    // create a panel for all our flow control buttons
    JPanel control_flow_buttons = new JPanel();
    control_flow_buttons.setLayout(new GridLayout(1, 6));
    control_flow_buttons.add(start_stop);
    control_flow_buttons.add(reset);
    control_flow_buttons.add(reconfigure);

    // add our components to the window
    species_control.add(species_list_l);
    species_control.add(species_select_list);
    control_window.add(species_control, BorderLayout.WEST);
    control_window.add(field_controls, BorderLayout.CENTER);
    control_window.add(control_flow_buttons, BorderLayout.SOUTH);
    control_window.setLocation(620, 0);
    control_window.setVisible(true);
  }
Ejemplo n.º 5
0
  public SQLiteDataBrowser() {
    SQLiteDbManager dbManager = new SQLiteDbManager();

    setLayout(new BorderLayout());

    showTablesList = new JList();
    showTablesList.setLayoutOrientation(JList.VERTICAL_WRAP);
    showTablesList.setSelectedIndex(ListSelectionModel.SINGLE_SELECTION);
    showTablesList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    showTablesList.setFont(new Font("Times New Roman", Font.PLAIN, 13));
    showTablesList.setDragEnabled(false);
    showTablesList.setFixedCellWidth(150);
    showTablesList.setVisibleRowCount(-1);
    showTablesList.setEnabled(false);

    showTablesListScroller = new JScrollPane(showTablesList);
    showTablesListScroller.setBorder(
        BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "List of Tables"));
    showTablesListScroller.setPreferredSize(new Dimension(160, this.getHeight()));

    add(showTablesListScroller, BorderLayout.EAST);

    loadDbPanel = new JPanel(new FlowLayout());
    loadDbPanel.setBackground(new Color(0xe8e8e8));
    loadDbPanel.setPreferredSize(new Dimension(getWidth(), 40));

    loadDbLabel = new JLabel("Load SQLite Database: ");
    loadDbLabel.setToolTipText("Possible extensions being .sqlite|.sqlite3|.db|.db3");

    loadedDbPath = new JTextField("Click browse to choose the database file.", 60);
    loadedDbPath.setForeground(Color.GRAY);
    loadedDbPath.setFont(new Font("Times New Roman", Font.ITALIC, 13));
    loadedDbPath.setEditable(false);

    lastFolderLocation = new File(Utils.getUserHome());
    fc = new JFileChooser(lastFolderLocation);

    browseDb = new JButton("Browse");
    browseDb.addActionListener(
        actionEvent -> {
          int retVal = fc.showOpenDialog(SQLiteDataBrowser.this);
          if (retVal == JFileChooser.APPROVE_OPTION) {
            File dbPath = fc.getSelectedFile();
            if (Utils.checkIfSQLiteDb(dbPath)) {
              loadedDbPath.setText(dbPath.toString());
              lastFolderLocation = fc.getCurrentDirectory();
              new SwingWorker<Void, Void>() {

                @Override
                protected Void doInBackground() throws Exception {
                  try {
                    dbManager.setDbPath(dbPath.toString());
                    dbManager.initialize();
                    showTablesList.setListData(dbManager.getTables().toArray());
                    showTablesList.setEnabled(true);
                  } catch (SQLException e) {
                    e.printStackTrace();
                  }
                  return null;
                }
              }.execute();
            } else {
              JOptionPane.showMessageDialog(
                  SQLiteDataBrowser.this,
                  "The Selected file is not in SQLite Format",
                  "File Format Error",
                  JOptionPane.ERROR_MESSAGE);
              loadedDbPath.setText("Click browse to choose the database file.");
            }
          }
        });

    loadDbPanel.add(loadDbLabel);
    loadDbPanel.add(loadedDbPath);
    loadDbPanel.add(browseDb);

    loadDbRecords = new JLabel("Records Fetched (Rows x Cols): ");
    loadDbRecords.setFont(new Font("Times New Roman", Font.ITALIC, 12));
    loadDbPanel.add(loadDbRecords);

    loadDbRecordsCount = new JLabel();
    loadDbRecordsCount.setFont(new Font("Times New Roman", Font.ITALIC, 12));
    loadDbPanel.add(loadDbRecordsCount);

    final class DataBrowserTableModal extends DefaultTableModel {

      public DataBrowserTableModal() {}

      public DataBrowserTableModal(Object[][] tableData, Object[] colNames) {
        super(tableData, colNames);
      }

      @Override
      public void setDataVector(Object[][] tableData, Object[] colNames) {
        super.setDataVector(tableData, colNames);
      }

      @Override
      public boolean isCellEditable(int row, int column) {
        return false;
      }
    }

    DataBrowserTableModal tableModal = new DataBrowserTableModal();
    defaultTableModel = tableModal;

    table = new JTable();
    table.setModel(defaultTableModel);

    showTablesList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            JList list = (JList) evt.getSource();
            if (evt.getClickCount() == 2) {
              String tableName = list.getSelectedValue().toString();

              new SwingWorker<Void, Void>() {

                @Override
                protected Void doInBackground() throws Exception {
                  try {
                    ResultSet rs = dbManager.executeQuery("SELECT * from " + tableName);
                    Vector<String> columnNames = dbManager.getColumnNames(rs);
                    Vector<Vector<Object>> tableData = new Vector<>();
                    while (rs.next()) {
                      Vector<Object> vector = new Vector<>();

                      for (int i = 1; i <= columnNames.size(); i++) {
                        vector.add(rs.getObject(i));
                      }
                      tableData.add(vector);
                    }
                    defaultTableModel.setDataVector(tableData, columnNames);
                  } catch (SQLException e) {
                    e.printStackTrace();
                  }

                  loadDbRecordsCount.setText(
                      defaultTableModel.getRowCount() + " x " + defaultTableModel.getColumnCount());

                  if (defaultTableModel.getColumnCount() < 5) {
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
                  } else {
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
                  }

                  return null;
                }
              }.execute();
            }
          }
        });

    tableScrollPane = new JScrollPane(table);
    tableScrollPane.setHorizontalScrollBarPolicy(
        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    tableScrollPane.setPreferredSize(new Dimension(getWidth(), getHeight()));
    add(tableScrollPane, BorderLayout.CENTER);

    add(loadDbPanel, BorderLayout.NORTH);
  }
Ejemplo n.º 6
0
  public FavouritesView(Favourite favouritesModel) {
    super();

    // Set the favourites model, and register ourselves as an observer, so we can be notified
    // of any changes to the model.
    _favouritesModel = favouritesModel;
    _favouritesModel.addObserver(this);

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.setBorder(BorderFactory.createTitledBorder("Favourites"));

    JPanel listPanel = new JPanel();
    listPanel.setLayout(new BoxLayout(listPanel, BoxLayout.Y_AXIS));
    listPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));

    _favouritesList = new JList();
    _favouritesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _favouritesList.setLayoutOrientation(JList.VERTICAL);

    // Fetch initial favourited stations.
    updateList();

    _favouritesScroller = new JScrollPane(_favouritesList);
    _favouritesScroller.setHorizontalScrollBarPolicy(
        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    _favouritesScroller.setVerticalScrollBarPolicy(
        ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    listPanel.add(_favouritesScroller);

    _remove = new JButton("Remove");
    _remove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // Remove the selected station from the user's favourites.
            Station station = (Station) _favouritesList.getSelectedValue();
            if (station != null) {
              _favouritesModel.removeStation(station);
            }
          }
        });

    _select = new JButton("Select");
    _select.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // Display the selected favourite.
            if (_favouritesList.getSelectedValue() != null)
              _favouritesModel.setCurrentStation((Station) _favouritesList.getSelectedValue());
          }
        });

    JPanel buttonPanel = new JPanel();
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 25));

    buttonPanel.add(_select);
    buttonPanel.add(_remove);

    this.add(listPanel);
    this.add(buttonPanel);
  }
Ejemplo n.º 7
0
  /** @param parent Parent Frame of this panel */
  public AdminView(tester parent) {
    padre = parent;
    try { // Start Setting the look and feel to nimbus
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception e) {
      // If Nimbus is not available, set gui to CrossPlatform
      try {
        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      } catch (ClassNotFoundException a) {
        // TODO Auto-generated catch block
      } catch (InstantiationException b) {
        // TODO Auto-generated catch block
      } catch (IllegalAccessException c) {
        // TODO Auto-generated catch block
      } catch (UnsupportedLookAndFeelException d) {
        // TODO Auto-generated catch block
      }
    }
    try { // start up the controller
      control = new Controller();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
    } catch (IOException e) {
      // TODO Auto-generated catch block
    }
    // make the panels
    JPanel total = new JPanel(new BorderLayout());
    JPanel test = new JPanel();
    JPanel users = new JPanel();
    JPanel info = new JPanel();
    // set any gaps i want
    Buttons.setVgap(10);
    Info.setHgap(20);
    // set layouts for the panels
    users.setLayout(List);
    test.setLayout(Buttons);
    info.setLayout(Info);
    // Set up the list
    listModel = new DefaultListModel<String>();
    userList = new JList<String>(listModel);
    userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // only one thing at a time
    userList.setVisibleRowCount(10);
    populateUsers();
    // userList.setPreferredSize(new Dimension(200,200));

    userList.setLayoutOrientation(JList.VERTICAL); // lists items vertically
    // put a scroll pane all up in
    JScrollPane userscroller =
        new JScrollPane(
            userList,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    userscroller.setPreferredSize(new Dimension(200, 200));

    // Initialize buttons
    add_user = new JButton("Add User");
    add_user.setPreferredSize(new Dimension(100, 20));
    delete_user = new JButton("Delete User");
    delete_user.setPreferredSize(new Dimension(100, 20));
    logout = new JButton("Logout");
    logout.setPreferredSize(new Dimension(100, 20));
    // add listeners
    add_user.addActionListener(this);
    add_user.setActionCommand("Add");
    delete_user.addActionListener(this);
    delete_user.setActionCommand("Delete");
    logout.addActionListener(this);
    logout.setActionCommand("Logout");
    // add to panels
    test.add(add_user);
    test.add(delete_user);
    test.add(logout);
    test.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); // spacing!
    users.add(userscroller);
    users.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 10)); // spacing!

    total.add(users); // everything is contained in total
    total.add(test, BorderLayout.WEST);
    total.setBorder(BorderFactory.createRaisedSoftBevelBorder()); // nice border
    total.setBorder(BorderFactory.createTitledBorder("Welcome Admin"));
    add(total);
  }
Ejemplo n.º 8
0
  private void initializeComponents() {
    this.setTitle("Synchro - Kopierassistent");
    this.setBounds(0, 0, 550, 600);

    this.setResizable(true);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(this);

    mainPanel = new JPanel();
    mainPanel.setBounds(0, 0, this.getWidth() - 20, 25);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    mainPanel.setLayout(null);

    btnBackup = new JButton("Backup");
    btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight());
    btnBackup.addActionListener(this);
    mainPanel.add(btnBackup);

    this.add(mainPanel);

    fcPanel = new JPanel();
    fcPanel.setBounds(10, 40, this.getWidth(), 260);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    fcPanel.setLayout(null);

    quellLabel = new JLabel("Bitte Quellverzeichnis auswählen");
    quellLabel.setBounds(10, 5, 320, 20);
    fcPanel.add(quellLabel);

    quellListModel = new DefaultListModel<>();
    quellJList = new JList<ListItem>(quellListModel);
    quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    quellJList.setLayoutOrientation(JList.VERTICAL);
    quellJList.addListSelectionListener(this);

    listBoxScroller = new JScrollPane(quellJList);
    listBoxScroller.setBounds(0, 30, 315, 100);
    fcPanel.add(listBoxScroller);

    btnQAuswahl = new JButton("Quellverz. hinzufügen");
    btnQAuswahl.setBounds(320, 30, 200, 25);
    btnQAuswahl.addActionListener(this);
    fcPanel.add(btnQAuswahl);
    btnQEntfernen = new JButton("Quellverz. entfernen");
    btnQEntfernen.setBounds(320, 60, 200, 25);
    btnQEntfernen.addActionListener(this);
    fcPanel.add(btnQEntfernen);

    zielLabel = new JLabel("Bitte Zielverzeichnis auswählen");
    zielLabel.setBounds(10, 135, 320, 20);
    fcPanel.add(zielLabel);

    zielListModel = new DefaultListModel<>();
    zielJList = new JList<ListItem>(zielListModel);
    zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    zielJList.setLayoutOrientation(JList.VERTICAL);
    zielJList.addListSelectionListener(this);

    listBoxScroller2 = new JScrollPane(zielJList);
    listBoxScroller2.setBounds(0, 160, 315, 100);
    fcPanel.add(listBoxScroller2);

    btnZAuswahl = new JButton("Zielverz. hinzufügen");
    btnZAuswahl.setBounds(320, 160, 200, 25);
    btnZAuswahl.addActionListener(this);
    fcPanel.add(btnZAuswahl);
    btnZEntfernen = new JButton("Zielverz. entfernen");
    btnZEntfernen.setBounds(320, 190, 200, 25);
    btnZEntfernen.addActionListener(this);
    fcPanel.add(btnZEntfernen);
    this.add(fcPanel);

    ButtonGroup bGrp = new ButtonGroup();

    optionPanel = new JPanel();
    optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90);
    optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90));
    // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    optionPanel.setLayout(new GridLayout(3, 1));

    nUebSchr = new JRadioButton("Keine Dateien überschreiben");
    nUebSchr.addItemListener(this);
    bGrp.add(nUebSchr);
    optionPanel.add(nUebSchr);

    ueSchr = new JRadioButton("Neuere Dateien überschreiben");
    ueSchr.addItemListener(this);
    bGrp.add(ueSchr);
    optionPanel.add(ueSchr);

    aUeSchr = new JRadioButton("Alle Dateien überschreiben");
    aUeSchr.addItemListener(this);
    bGrp.add(aUeSchr);
    optionPanel.add(aUeSchr);

    this.add(optionPanel);

    syncPanel = new JPanel();
    syncPanel.setBounds(
        10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25);
    // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    syncPanel.setLayout(new BorderLayout());

    btnSync = new JButton("Sync it!");
    btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnSync.addActionListener(this);
    btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    syncPanel.add(btnSync, BorderLayout.LINE_START);

    btnAbbruch = new JButton("Abbrechen");
    btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnAbbruch.addActionListener(this);
    btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setVisible(false);
    syncPanel.add(btnAbbruch, BorderLayout.LINE_END);

    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setBorderPainted(true);
    progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3)));
    progressBar.setForeground(Color.RED);
    progressBar.setStringPainted(true);
    progressBar.setVisible(true);
    syncPanel.add(progressBar, BorderLayout.CENTER);
    this.add(syncPanel);

    logPanel = new JPanel();
    logPanel.setBounds(
        10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105);
    logPanel.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setMargin(new Insets(3, 3, 3, 3));
    textArea.setBackground(Color.black);
    textArea.setForeground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);
    textArea.setFocusable(false);
    textAreaScroller = new JScrollPane(textArea);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50);

    logPanel.add(textAreaScroller, BorderLayout.CENTER);
    this.add(logPanel, BorderLayout.SOUTH);
  }
Ejemplo n.º 9
0
  public Container StockSearchScreen() {
    StockSScreen.setLayout(new GridLayout(4, 0));

    // Font for the title
    Font newFont = new Font("Aerial", Font.BOLD, 32);

    // Panels for the different parts of the screen.
    JPanel SearchP = new JPanel();
    JPanel buttonP = new JPanel();
    JPanel ResultP = new JPanel();
    //	ResultP.setLayout(new GridLayout(2,0));
    SearchP.setLayout(new GridLayout(5, 0));

    // Search text area
    // JTextField Searching = new JTextField("Input Search");
    Days = new JTextField("number of days");
    JLabel title = new JLabel("Rental");

    title.setFont(newFont);

    // details.setPreferredSize(new Dimension(20,30));
    // Results are put into textarea
    JTextArea results = new JTextArea("Results Displayed here");
    results.setEditable(false);
    results.setSize(50, 2500);
    JLabel resultsa = new JLabel();

    scroll = new JScrollPane(Films);

    Films.setLayoutOrientation(JList.VERTICAL);
    Films.setVisibleRowCount(5);

    Films.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    scroll.setPreferredSize(new Dimension(650, 150));
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    results.add(resultsa);

    //	SearchP.add(Searching);

    SearchP.add(Searched);
    SearchP.add(Display_instock);
    ResultP.add(scroll);
    ResultP.add(Days);
    buttonP.add(confirm);
    buttonP.add(goBack);

    // Set the action listeners for the buttons
    Searched.addActionListener(this);
    cancel.addActionListener(this);
    goBack.addActionListener(this);
    confirm.addActionListener(this);

    Display_instock.addActionListener(this);

    StockSScreen.add(title); // ,BorderLayout.NORTH);
    StockSScreen.add(SearchP); // ,BorderLayout.CENTER);
    StockSScreen.add(ResultP); // ,BorderLayout.CENTER);
    StockSScreen.add(buttonP); // ,BorderLayout.SOUTH);

    return StockSScreen;
  }
Ejemplo n.º 10
0
    public ExampleField(ExampleOption option) {
      super(option);

      model = new DefaultListModel();
      model.addListDataListener(
          new ListDataListener() {
            @Override
            public void intervalAdded(ListDataEvent e) {
              fireChangeEvent();
            }

            @Override
            public void intervalRemoved(ListDataEvent e) {
              fireChangeEvent();
            }

            @Override
            public void contentsChanged(ListDataEvent e) {
              fireChangeEvent();
            }
          });

      final JList list =
          new JList(model) {
            @Override
            public Dimension getPreferredScrollableViewportSize() {
              return new Dimension(3 * CELL_SIZE, 2 * CELL_SIZE);
            }
          };
      list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
      list.setVisibleRowCount(0);
      list.setFixedCellHeight(CELL_SIZE);
      list.setFixedCellWidth(CELL_SIZE);
      list.setTransferHandler(
          new URIImportTransferHandler() {
            @Override
            public boolean canImport(TransferSupport support) {
              support.setShowDropLocation(false);
              return super.canImport(support);
            }

            @Override
            public boolean importData(TransferSupport support) {
              try {
                List<BufferedImage> images = new ArrayList<BufferedImage>();
                for (URI u : getURIs(support)) {
                  try {
                    images.add(ImageIO.read(u.toURL()));
                  } catch (IOException e) {
                  }
                }
                addExamples(images);
                return true;
              } catch (IOException e) {
                return false;
              } catch (UnsupportedFlavorException e) {
                return false;
              } catch (URISyntaxException e) {
                return false;
              }
            }
          });
      list.setCellRenderer(
          new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(
                JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
              super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

              Example example = (Example) value;

              setHorizontalAlignment(SwingConstants.CENTER);
              setText(null);
              setIcon(example.getIcon());
              setBorder(BorderFactory.createEmptyBorder());

              return this;
            }
          });
      JScrollPane jsp = new JScrollPane(list);
      jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

      final JButton remove = new JButton("Remove");
      remove.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              int[] indices = list.getSelectedIndices();
              for (int i = indices.length - 1; i >= 0; i--) {
                model.remove(indices[i]);
              }
            }
          });
      list.addListSelectionListener(
          new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
              remove.setEnabled(list.getSelectedIndex() != -1);
            }
          });
      remove.setEnabled(false);

      panel = new JPanel(new GridBagLayout());
      // Add list
      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 1;
      c.fill = GridBagConstraints.BOTH;
      panel.add(jsp, c);
      // Add remove button
      c = new GridBagConstraints();
      c.gridx = 0;
      c.anchor = GridBagConstraints.WEST;
      panel.add(remove, c);
    }
Ejemplo n.º 11
0
  @Analyzer(
      name = "Event Data Attribute Visualizer",
      names = {"Log"})
  public JComponent analyze(LogReader log) {
    /*
     * this plugin takes a log, shows a list of available data-attributes
     * and a list of cases After selecting a data-attribute (and possibly a
     * case) a graph is made of the value of the data-attribute against
     * either time or against the sequence of events.
     *
     * input: log with data attributes gui-input: select a data-attribute,
     * choose time or event-sequence, and possibly a case
     *
     * internally : if not caseselected -> scatterplot of values against
     * time/event-number else show graph for value against time/event-number
     *
     * createGraph : check number / string
     */
    mylog = log;
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());

    chartPanel = new JPanel();
    chartPanel.setLayout(new BoxLayout(chartPanel, BoxLayout.PAGE_AXIS));

    optionsPanel = new JPanel();
    optionsPanel.setLayout(new SpringLayout());

    JLabel attributelabel = new JLabel("Select attributes to use");
    attributeslist = new JList(getAttributes());
    attributeslist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    attributeslist.setLayoutOrientation(JList.VERTICAL);
    optionsPanel.add(attributelabel);
    optionsPanel.add(attributeslist);

    JLabel xlabel = new JLabel("Chart type");
    String[] xvalues = new String[4];
    xvalues[0] = " Attribute values against event sequence";
    xvalues[1] = "Attribute values against timestamps";
    xvalues[2] = "Average attribute values against event sequence";
    xvalues[3] = "Average attribute values against timestamps";
    xbox = new JComboBox(xvalues);
    xbox.setMaximumSize(xbox.preferredSize());
    xbox.setSelectedIndex(1);

    xbox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            if (cb.getSelectedIndex() == 3) {
              BSpinner.setVisible(true);
            } else {
              BSpinner.setVisible(false);
            }
          };
        });

    optionsPanel.add(xlabel);
    optionsPanel.add(xbox);

    JLabel timelabel = new JLabel("show time by ");
    String[] timevalues = new String[4];
    timevalues[0] = "second";
    timevalues[1] = "minute";
    timevalues[2] = "hour";
    timevalues[3] = "day";
    timebox = new JComboBox(timevalues);
    timebox.setMaximumSize(timebox.preferredSize());
    timebox.setSelectedIndex(1);
    optionsPanel.add(timelabel);
    optionsPanel.add(timebox);

    SpinnerModel Bmodel = new SpinnerNumberModel(10, 2, 1000000, 1);
    BSpinner = new JSpinner(Bmodel);
    JLabel BLabel = new JLabel("Select histogram barsize");
    JLabel B2Label = new JLabel("used for average against timestamps");
    BSpinner.setMaximumSize(BSpinner.preferredSize());
    BSpinner.setVisible(false);
    optionsPanel.add(BLabel);
    optionsPanel.add(B2Label);
    optionsPanel.add(BSpinner);

    JButton updatebutton = new JButton("update");
    updatebutton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            Object[] sels = attributeslist.getSelectedValues();
            String[] els = new String[sels.length];
            for (int i = 0; i < sels.length; i++) {
              els[i] = sels[i].toString();
            }

            long timesize = 1000;
            switch (timebox.getSelectedIndex()) {
              case 0:
                timesize = 1000;
                break;
              case 1:
                timesize = 1000 * 60;
                break;
              case 2:
                timesize = 1000 * 60 * 60;
                break;
              case 3:
                timesize = 1000 * 60 * 60 * 24;
                break;
            }

            String xname = null;
            JFreeChart mychart = null;
            if (xbox.getSelectedIndex() == 0) {
              data = getDataAttributes(els, false, timesize);
              xname = "Event sequence";
              mychart =
                  ChartFactory.createScatterPlot(
                      "Scatterplot of all values",
                      xname,
                      "attribute value",
                      data,
                      PlotOrientation.VERTICAL,
                      true,
                      true,
                      false);
            } else if (xbox.getSelectedIndex() == 1) {
              data = getDataAttributes(els, true, timesize);
              xname = "Time(" + timebox.getSelectedItem() + ") since beginning of the process";
              mychart =
                  ChartFactory.createScatterPlot(
                      "Scatterplot of all values",
                      xname,
                      "attribute value",
                      data,
                      PlotOrientation.VERTICAL,
                      true,
                      true,
                      false);
            } else if (xbox.getSelectedIndex() == 2) {
              xname = "Event sequence";
              data = getHistrogrammedDataAttributes(els, 1, 1);
              mychart =
                  ChartFactory.createXYLineChart(
                      "Average values",
                      xname,
                      "attribute value",
                      data,
                      PlotOrientation.VERTICAL,
                      true,
                      true,
                      false);
              mychart.setBackgroundPaint(Color.white);
              XYPlot plot = mychart.getXYPlot();

              plot.setBackgroundPaint(Color.white);
              plot.setDomainGridlinePaint(Color.white);
              plot.setRangeGridlinePaint(Color.white);

              DeviationRenderer renderer = new DeviationRenderer(true, true);
              renderer.setSeriesStroke(
                  0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
              renderer.setSeriesStroke(0, new BasicStroke(2.0f));
              renderer.setSeriesStroke(1, new BasicStroke(2.0f));
              renderer.setSeriesStroke(2, new BasicStroke(2.0f));
              renderer.setSeriesStroke(3, new BasicStroke(2.0f));
              renderer.setSeriesFillPaint(0, Color.red);
              renderer.setSeriesFillPaint(1, Color.blue);
              renderer.setSeriesFillPaint(2, Color.green);
              renderer.setSeriesFillPaint(3, Color.orange);
              plot.setRenderer(renderer);
              // change the auto tick unit selection to integer units
              // only...
              NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
              // yAxis.setAutoRangeIncludesZero(false);
              yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

              NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
              xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            } else {
              xname = "Time(" + timebox.getSelectedItem() + "s) since beginning of the process";
              data =
                  getHistrogrammedDataAttributes(
                      els, ((Integer) BSpinner.getValue()) * timesize, timesize);
              mychart =
                  ChartFactory.createXYLineChart(
                      "Average values",
                      xname,
                      "attribute value",
                      data,
                      PlotOrientation.VERTICAL,
                      true,
                      true,
                      false);
              mychart.setBackgroundPaint(Color.white);
              XYPlot plot = mychart.getXYPlot();

              plot.setBackgroundPaint(Color.white);
              plot.setDomainGridlinePaint(Color.white);
              plot.setRangeGridlinePaint(Color.white);

              DeviationRenderer renderer = new DeviationRenderer(true, true);
              renderer.setSeriesStroke(
                  0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
              renderer.setSeriesStroke(0, new BasicStroke(2.0f));
              renderer.setSeriesStroke(1, new BasicStroke(2.0f));
              renderer.setSeriesStroke(2, new BasicStroke(2.0f));
              renderer.setSeriesStroke(3, new BasicStroke(2.0f));
              renderer.setSeriesFillPaint(0, Color.red);
              renderer.setSeriesFillPaint(1, Color.blue);
              renderer.setSeriesFillPaint(2, Color.green);
              renderer.setSeriesFillPaint(3, Color.orange);
              plot.setRenderer(renderer);
              // change the auto tick unit selection to integer units
              // only...
              NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
              // yAxis.setAutoRangeIncludesZero(false);
              yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            }

            ChartPanel mychartpanel = new ChartPanel(mychart);
            mychartpanel.setBackground(Color.white);
            chartPanel.removeAll();
            chartPanel.add(mychartpanel);
            chartPanel.updateUI();
          };
        });
    optionsPanel.add(updatebutton);

    JSplitPane splitPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, optionsPanel, chartPanel);

    SpringUtils.makeCompactGrid(
        optionsPanel,
        10,
        1, // rows, cols
        6,
        2, // initX, initY
        6,
        2); // xPad, yPad

    mainPanel.add(splitPanel, BorderLayout.CENTER);
    return mainPanel;
  }