Java Code Examples for com.alee.laf.label.WebLabel#setFont()

The following examples show how to use com.alee.laf.label.WebLabel#setFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotesTabPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void initializeUI() {
	uiDone = true;
	
	// Initialize location header.
	WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
	topContentPanel.add(titlePane);

	WebLabel titleLabel = new WebLabel(Msg.getString("NotesTabPanel.title"), WebLabel.CENTER); //$NON-NLS-1$
	titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
	// titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
	titlePane.add(titleLabel);
	
	// Create notes panel
	WebPanel notesPanel = new WebPanel(new BorderLayout(5, 5));
	notesPanel.setBorder(new MarsPanelBorder());
	notesPanel.setBorder(new EmptyBorder(1, 1, 1, 1));
	centerContentPanel.add(notesPanel);
	
	notesCache = unit.getNotes();
	
	textArea = new WebTextArea(StyleId.textareaDecorated);
	notesPanel.add(textArea);
	
	if (notesCache == null || notesCache.equals(""))
		textArea.setInputPrompt("Enter Here");
	else {
		textArea.append(notesCache);
	}

}
 
Example 2
Source File: TabPanelSocial.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		// Create relationship label panel.
		WebPanel relationshipLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(relationshipLabelPanel);

		// Create relationship label
		WebLabel relationshipLabel = new WebLabel(Msg.getString("TabPanelSocial.label"), WebLabel.CENTER); //$NON-NLS-1$
		relationshipLabel.setFont(new Font("Serif", Font.BOLD, 16));
		relationshipLabelPanel.add(relationshipLabel);

		// Create relationship scroll panel
		WebScrollPane relationshipScrollPanel = new WebScrollPane();
//		relationshipScrollPanel.setBorder(new MarsPanelBorder());
		centerContentPanel.add(relationshipScrollPanel);

		// Create relationship table model
		relationshipTableModel = new RelationshipTableModel(person);

		// Create relationship table
		relationshipTable = new ZebraJTable(relationshipTableModel);
		relationshipTable.setPreferredScrollableViewportSize(new Dimension(225, 100));
		relationshipTable.getColumnModel().getColumn(0).setPreferredWidth(80);
		relationshipTable.getColumnModel().getColumn(1).setPreferredWidth(80);
		relationshipTable.getColumnModel().getColumn(2).setPreferredWidth(40);
		relationshipTable.setRowSelectionAllowed(true);
		
		// For single clicking on a person to pop up his person window.
		//relationshipTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);	
		//relationshipTable.getSelectionModel().addListSelectionListener(this); 

		// Add a mouse listener to hear for double-clicking a person (rather than single click using valueChanged()
		relationshipTable.addMouseListener(new MouseAdapter() {
		    public void mousePressed(MouseEvent me) {
		    	JTable table =(JTable) me.getSource();
		        Point p = me.getPoint();
		        int row = table.rowAtPoint(p);
		        int col = table.columnAtPoint(p);
		        if (me.getClickCount() == 2) {
		            if (row > 0 && col > 0) {
		    			Person selectedPerson = (Person) relationshipTable.getValueAt(row, 1);  			
		    			if (selectedPerson != null) desktop.openUnitWindow(selectedPerson, false);
		    	    }
		        }
		    }
		});
		
		relationshipScrollPanel.setViewportView(relationshipTable);

		// Align the content to the center of the cell
		DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		renderer.setHorizontalAlignment(SwingConstants.RIGHT);
		relationshipTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
		relationshipTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
		relationshipTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
		
		// Added sorting
		relationshipTable.setAutoCreateRowSorter(true); // in conflict with valueChanged(), throw exception if clicking on a person

		TableStyle.setTableStyle(relationshipTable);
	}
 
Example 3
Source File: TabPanelBuildings.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
						
		List<Building> buildings = settlement.getBuildingManager().getSortedBuildings();

		// Set building to the first element on the list
		// Add if-clause for opening the building panel via the right click popup menu
		if (building == null) {
			building = buildings.get(0);
			setCurrentBuilding(building);
		}

		// Create building select panel.
		// Add buildingInfoPanel & buildingTitleLabel
		WebPanel buildingInfoPanel = new WebPanel(new GridLayout(2, 1, 0, 0));
		// buildingInfoPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(buildingInfoPanel);
		panelList.add(buildingInfoPanel);

		WebLabel titleLabel = new WebLabel("Buildings", WebLabel.CENTER);
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		// titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
		buildingInfoPanel.add(titleLabel);
		titleLabel.setOpaque(false);
		titleLabel.setBackground(new Color(0, 0, 0, 128));

		WebPanel buildingSelectPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		buildingInfoPanel.add(buildingSelectPanel);
		panelList.add(buildingSelectPanel);

		// Create building combo box model.
		comboBoxModel = new DefaultComboBoxModel<Building>();

		buildingsCache = new ArrayList<Building>(buildings);
		for (Building b : buildingsCache) {
			comboBoxModel.addElement(b);
		}
		// Create building list.
		comboBox = new JComboBoxMW<Building>(comboBoxModel);
//		comboBox.setRenderer(new PromptComboBoxRenderer("Select a Building"));
		// comboBox.setOpaque(false);
		// comboBox.setBackground(new Color(0,0,0,128));
		// comboBox.setBackground(new Color(255,229,204));
		// comboBox.setForeground(Color.orange);
		comboBox.addActionListener(this);
		comboBox.setMaximumRowCount(10);
		comboBox.setBorder(null);

		buildingSelectPanel.add(comboBox);

		// Create building display panel.
		buildingDisplayPanel = new WebPanel();
		buildingLayout = new CardLayout();
		buildingDisplayPanel.setLayout(buildingLayout);
//		buildingDisplayPanel.setBorder(new MarsPanelBorder());
		centerContentPanel.add(buildingDisplayPanel);
		panelList.add(buildingDisplayPanel);

		// Create building panels
		buildingPanels = new ArrayList<BuildingPanel>();
		count = 0;
		Iterator<Building> iter = buildings.iterator();
		while (iter.hasNext()) {
			BuildingPanel panel = new BuildingPanel(String.valueOf(count), iter.next(), desktop);
			buildingPanels.add(panel);
			buildingDisplayPanel.add(panel, panel.getPanelName());
			count++;
		}

		setPanelTranslucent();
	}
 
Example 4
Source File: BuildingPanelPower.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param building the building the panel is for.
 * @param desktop The main desktop.
 */
public BuildingPanelPower(Building building, MainDesktopPane desktop) {

	// Use BuildingFunctionPanel constructor
	super(building, desktop);

	// Check if the building is a power producer.
	isProducer = building.hasFunction(FunctionType.POWER_GENERATION);
	generator = building.getPowerGeneration();
	
	// Set the layout
	setLayout(new BorderLayout());

	// 2014-11-21 Changed font type, size and color and label text
	WebLabel titleLabel = new WebLabel(
			Msg.getString("BuildingPanelPower.title"), //$NON-NLS-1$
			WebLabel.CENTER);		
	titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
	add(titleLabel, BorderLayout.NORTH);
	
	WebPanel springPanel = new WebPanel(new SpringLayout());
	add(springPanel, BorderLayout.CENTER);
	
	// Prepare power status label.
	powerStatusCache = building.getPowerMode();
	powerStatusLabel = new WebLabel(
			Msg.getString("BuildingPanelPower.powerStatus"), //$NON-NLS-1$
			WebLabel.RIGHT);
	springPanel.add(powerStatusLabel);
	
	WebPanel wrapper1 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING));
	statusTF = new WebTextField(powerStatusCache.getName());
	statusTF.setEditable(false);
	statusTF.setColumns(7);
	statusTF.setPreferredSize(new Dimension(120, 25));
	wrapper1.add(statusTF);
	springPanel.add(wrapper1);

	// If power producer, prepare power producer label.
	if (isProducer) {
		//PowerGeneration generator = building.getPowerGeneration();//(PowerGeneration) building.getFunction(FunctionType.POWER_GENERATION);
		powerCache = generator.getGeneratedPower();
		powerLabel = new WebLabel(
			Msg.getString("BuildingPanelPower.powerProduced"), //$NON-NLS-1$
			WebLabel.RIGHT);
		
		springPanel.add(powerLabel);
		
		WebPanel wrapper2 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING));
		producedTF = new WebTextField(formatter.format(powerCache) + kW);
		producedTF.setEditable(false);
		producedTF.setColumns(7);
		producedTF.setPreferredSize(new Dimension(120, 25));
		wrapper2.add(producedTF);
		springPanel.add(wrapper2);
	}

	// Prepare power used label.
	if (powerStatusCache == PowerMode.FULL_POWER) 
		usedCache = building.getFullPowerRequired();
	else if (powerStatusCache == PowerMode.POWER_DOWN) 
		usedCache = building.getPoweredDownPowerRequired();
	else usedCache = 0D;
	
	usedLabel = new WebLabel(
		Msg.getString("BuildingPanelPower.powerUsed"), //$NON-NLS-1$
		WebLabel.RIGHT
	);
	
	springPanel.add(usedLabel);
	
	WebPanel wrapper3 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING));
	usedTF = new WebTextField(formatter.format(usedCache) + kW);
	usedTF.setEditable(false);
	usedTF.setColumns(7);
	usedTF.setPreferredSize(new Dimension(120, 25));
	wrapper3.add(usedTF);
	springPanel.add(wrapper3);
	
	//Lay out the spring panel.
	if (isProducer) {
		SpringUtilities.makeCompactGrid(springPanel,
	                                3, 2, //rows, cols
	                                75, 10,        //initX, initY
	                                3, 1);       //xPad, yPad
	}
	else
		SpringUtilities.makeCompactGrid(springPanel,
                   2, 2, //rows, cols
                   75, 10,        //initX, initY
                   3, 1);       //xPad, yPad
	}
 
Example 5
Source File: BuildingPanelThermal.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param The panel for the Heating System
 * @param The main desktop
 */
//2014-10-28 mkung: Modified the structure of the constructor 
public BuildingPanelThermal(ThermalGeneration furnace, MainDesktopPane desktop) {
	super(furnace.getBuilding(), desktop);
	// Use BuildingFunctionPanel constructor
	//super(building, desktop);
	
	this.furnace = furnace;
	this.building = furnace.getBuilding();
	
	furnace = building.getThermalGeneration();//(ThermalGeneration) building.getFunction(BuildingFunction.THERMAL_GENERATION);	
		
	// Check if the building is a heat producer.
	hasFurnace = building.hasFunction(FunctionType.THERMAL_GENERATION);

	// If heat producer, prepare heat producer label.
	if (hasFurnace) {
		 setLayout(new GridLayout(3, 1, 0, 0));
		
		// 2014-11-21 Changed font type, size and color and label text
		WebLabel titleLabel = new WebLabel(
				Msg.getString("BuildingPanelThermal.title"), //$NON-NLS-1$
				WebLabel.CENTER);		
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		//titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
		add(titleLabel);
		
		// Prepare heat status label.
		heatStatusCache = building.getHeatMode();
		heatStatusLabel = new WebLabel(
			Msg.getString("BuildingPanelThermal.heatStatus", heatStatusCache.getName()), //$NON-NLS-1$
			WebLabel.CENTER
		);
		add(heatStatusLabel);	
			
		productionCache = furnace.getGeneratedHeat();		
		productionLabel = new WebLabel(	
			Msg.getString("BuildingPanelThermal.heatProduced", formatter.format(productionCache)), //$NON-NLS-1$
			WebLabel.CENTER
		);
		add(productionLabel);
	}
}
 
Example 6
Source File: BuildingPanelStorage.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param storage the storage building function.
 * @param desktop the main desktop.
 */
public BuildingPanelStorage(Storage storage, MainDesktopPane desktop) {

	// Use BuildingFunctionPanel constructor
	super(storage.getBuilding(), desktop);

	setLayout(new BorderLayout(0, 0));

	// Create storage label.
	WebLabel storageLabel = new WebLabel(Msg.getString("BuildingPanelStorage.title"), WebLabel.CENTER);
	storageLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//storageLabel.setForeground(new Color(102, 51, 0)); // dark brown

	WebPanel titlePanel = new WebPanel(new GridLayout(2,1,0,0));
	add(titlePanel, BorderLayout.NORTH);
	titlePanel.add(storageLabel);
	titlePanel.setOpaque(false);
	titlePanel.setBackground(new Color(0,0,0,128));

	WebLabel maxCapLabel = new WebLabel(Msg.getString("BuildingPanelStorage.maxCap"), WebLabel.CENTER);
	titlePanel.add(maxCapLabel);

	Map<Integer, Double> resourceStorage = storage.getResourceStorageCapacity();

	// Create resource storage panel.
	WebPanel resourceStoragePanel = new WebPanel(new GridLayout(resourceStorage.size(), 2, 0, 0));
	add(resourceStoragePanel, BorderLayout.CENTER);
	resourceStoragePanel.setOpaque(false);
	resourceStoragePanel.setBackground(new Color(0,0,0,128));

	SortedSet<Integer> keys = new TreeSet<Integer>(resourceStorage.keySet());
	for (Integer resource : keys) { 
		// Create resource label.
		WebLabel resourceLabel = new WebLabel(
				Conversion.capitalize(ResourceUtil.findAmountResourceName(resource)) 
				+ ":", WebLabel.LEFT);
		resourceStoragePanel.add(resourceLabel);

		double capacity = resourceStorage.get(resource);
		WebLabel capacityLabel = new WebLabel((int) capacity + " kg", WebLabel.RIGHT);
		resourceStoragePanel.add(capacityLabel);
	}
}
 
Example 7
Source File: BuildingPanelMedicalCare.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param medical the medical care building this panel is for.
 * @param desktop The main desktop.
 */
public BuildingPanelMedicalCare(MedicalCare medical, MainDesktopPane desktop) {

	// Use BuildingFunctionPanel constructor
	super(medical.getBuilding(), desktop);

	// Initialize data members
	this.medical = medical;

	// Set panel layout
	setLayout(new BorderLayout());

	// Create label panel
	WebPanel labelPanel = new WebPanel(new GridLayout(3, 1, 0, 0));
	add(labelPanel, BorderLayout.NORTH);
	labelPanel.setOpaque(false);
	labelPanel.setBackground(new Color(0,0,0,128));

	// Create medical care label
	// 2014-11-21 Changed font type, size and color and label text
	// 2014-11-21 Added internationalization for labels
	WebLabel medicalCareLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.title"), WebLabel.CENTER);
	medicalCareLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//medicalCareLabel.setForeground(new Color(102, 51, 0)); // dark brown
	labelPanel.add(medicalCareLabel);

	// Create sick bed label
	WebLabel sickBedLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.numberOfsickBeds",
			medical.getSickBedNum()), WebLabel.CENTER);
	labelPanel.add(sickBedLabel);

	// Create physician label
	physicianCache = medical.getPhysicianNum();
	physicianLabel = new WebLabel(Msg.getString("BuildingPanelMedicalCare.numberOfPhysicians",
			physicianCache), WebLabel.CENTER);
	labelPanel.add(physicianLabel);

	// Create scroll panel for medical table
	WebScrollPane scrollPanel = new WebScrollPane();
	scrollPanel.setPreferredSize(new Dimension(160, 80));
	add(scrollPanel, BorderLayout.CENTER);
    scrollPanel.getViewport().setOpaque(false);
    scrollPanel.getViewport().setBackground(new Color(0, 0, 0, 0));
    scrollPanel.setOpaque(false);
    scrollPanel.setBackground(new Color(0, 0, 0, 0));
       //scrollPanel.setBorder( BorderFactory.createLineBorder(Color.orange) );


	// Prepare medical table model
	medicalTableModel = new MedicalTableModel(medical);

	// Prepare medical table
	JTable medicalTable = new ZebraJTable(medicalTableModel);
	medicalTable.setCellSelectionEnabled(false);
	scrollPanel.setViewportView(medicalTable);
}
 
Example 8
Source File: BuildingPanelResearch.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param lab the research building this panel is for.
 * @param desktop The main desktop.
 */
public BuildingPanelResearch(Research lab, MainDesktopPane desktop) {

	// Use BuildingFunctionPanel constructor
	super(lab.getBuilding(), desktop);

	// Initialize data members
	this.lab = lab;

	// Set panel layout
	setLayout(new BorderLayout());

	// Prepare label panel
	WebPanel labelPanel = new WebPanel(new GridLayout(4, 1, 0, 0));
	add(labelPanel, BorderLayout.NORTH);
	labelPanel.setOpaque(false);
	labelPanel.setBackground(new Color(0,0,0,128));

	// Prepare research label
	WebLabel researchLabel = new WebLabel(Msg.getString("BuildingPanelResearch.title"), WebLabel.CENTER); //$NON-NLS-1$
	researchLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//researchLabel.setForeground(new Color(102, 51, 0)); // dark brown
	labelPanel.add(researchLabel);

	// Prepare researcher number label
	researchersCache = lab.getResearcherNum();
	researchersLabel = new WebLabel(Msg.getString("BuildingPanelResearch.numberOfResearchers", researchersCache), WebLabel.CENTER);
	labelPanel.add(researchersLabel);

	// Prepare researcher capacityLabel
	WebLabel researcherCapacityLabel = new WebLabel(Msg.getString("BuildingPanelResearch.researcherCapacity",
			lab.getLaboratorySize()),
			WebLabel.CENTER);
	labelPanel.add(researcherCapacityLabel);

	// Prepare specialties label
	WebLabel specialtiesLabel = new WebLabel(Msg.getString("BuildingPanelResearch.namesOfSpecialties"), WebLabel.CENTER);
	labelPanel.add(specialtiesLabel);

	// Get the research specialties of the building.
	ScienceType[] specialties = lab.getTechSpecialties();
	int size = specialties.length;

	WebTextArea specialtyTA = new WebTextArea();
	specialtyTA.setEditable(false);
	specialtyTA.setFont(new Font("SansSerif", Font.ITALIC, 12));
	specialtyTA.setColumns(7);

	// For each specialty, add specialty name panel.
	for (ScienceType specialty : specialties) {
		specialtyTA.append(" " + specialty.getName()+ " ");
		if (!specialty.equals(specialties[size-1]))
			//if it's NOT the last one
			specialtyTA.append("\n");
	}

	WebPanel listPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
	listPanel.add(specialtyTA);
	specialtyTA.setBorder(new MarsPanelBorder());

	add(listPanel, BorderLayout.CENTER);
	listPanel.setOpaque(false);
	listPanel.setBackground(new Color(0,0,0,128));

}
 
Example 9
Source File: BuildingPanelVehicleMaintenance.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param garage the vehicle maintenance function
 * @param desktop the main desktop
 */
public BuildingPanelVehicleMaintenance(VehicleMaintenance garage, MainDesktopPane desktop) {

	// Use BuildingFunctionPanel constructor
	super(garage.getBuilding(), desktop);

	// Initialize data members
	this.garage = garage;

	// Set panel layout
	setLayout(new BorderLayout());

	// Create label panel
	WebPanel labelPanel = new WebPanel(new GridLayout(3, 1, 0, 0));
	add(labelPanel, BorderLayout.NORTH);
	labelPanel.setOpaque(false);
	labelPanel.setBackground(new Color(0,0,0,128));
	
	// Create vehicle maintenance label
	// 2014-11-21 Changed font type, size and color and label text
	// 2014-11-21 Added internationalization for labels
	WebLabel vehicleMaintenanceLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.title"), WebLabel.CENTER);
	vehicleMaintenanceLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//vehicleMaintenanceLabel.setForeground(new Color(102, 51, 0)); // dark brown
	labelPanel.add(vehicleMaintenanceLabel);

	// Create vehicle number label
	vehicleNumberCache = garage.getCurrentVehicleNumber();
	vehicleNumberLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.numberOfVehicles",
			vehicleNumberCache), WebLabel.CENTER);
	labelPanel.add(vehicleNumberLabel);

	// Create vehicle capacity label
	int vehicleCapacity = garage.getVehicleCapacity();
	WebLabel vehicleCapacityLabel = new WebLabel(Msg.getString("BuildingPanelVehicleMaintenance.vehicleCapacity",
			vehicleCapacity), WebLabel.CENTER);
	labelPanel.add(vehicleCapacityLabel);	

	// Create vehicle list panel
	WebPanel vehicleListPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
	add(vehicleListPanel, BorderLayout.CENTER);
	vehicleListPanel.setOpaque(false);
	vehicleListPanel.setBackground(new Color(0,0,0,128));
	
	// Create scroll panel for vehicle list
	WebScrollPane vehicleScrollPanel = new WebScrollPane();
	vehicleScrollPanel.setPreferredSize(new Dimension(160, 60));
	vehicleListPanel.add(vehicleScrollPanel);
	vehicleScrollPanel.setOpaque(false);
	vehicleScrollPanel.setBackground(new Color(0,0,0,128));
	vehicleScrollPanel.getViewport().setOpaque(false);
	vehicleScrollPanel.getViewport().setBackground(new Color(0,0,0,128));
	
	// Create vehicle list model
	vehicleListModel = new DefaultListModel<Vehicle>();
	vehicleCache = new ArrayList<Vehicle>(garage.getVehicles());
	Iterator<Vehicle> i = vehicleCache.iterator();
	while (i.hasNext()) vehicleListModel.addElement(i.next());

	// Create vehicle list
	vehicleList = new JList<Vehicle>(vehicleListModel);
	vehicleList.addMouseListener(this);
	vehicleScrollPanel.setViewportView(vehicleList);
}
 
Example 10
Source File: BuildingPanelPowerStorage.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor.
 * @param storage The power storage building function.
 * @param desktop The main desktop.
 */
public BuildingPanelPowerStorage(PowerStorage storage, MainDesktopPane desktop) {

	// Use BuildingFunctionPanel constructor
	super(storage.getBuilding(), desktop);

	this.storage = storage;

	// Set the layout
	setLayout(new BorderLayout());

	// 2014-11-21 Changed font type, size and color and label text
	WebLabel titleLabel = new WebLabel(
			Msg.getString("BuildingPanelPowerStorage.title"), //$NON-NLS-1$
			WebLabel.CENTER);		
	titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
	//titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
	add(titleLabel, BorderLayout.NORTH);
	
	WebPanel springPanel = new WebPanel(new SpringLayout());
	add(springPanel, BorderLayout.CENTER);
	
	// Create capacity label.
	capacityCache = Math.round(storage.getCurrentMaxCapacity() *10.0)/10.0;;
	capacityLabel = new WebLabel(
			Msg.getString("BuildingPanelPowerStorage.cap"), //$NON-NLS-1$
			WebLabel.CENTER);		
	springPanel.add(capacityLabel);
	
	WebPanel wrapper1 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING));
	capTF = new WebTextField(formatter.format(capacityCache) + kWh);
	capTF.setEditable(false);
	capTF.setColumns(7);
	capTF.setPreferredSize(new Dimension(120, 25));
	wrapper1.add(capTF);
	springPanel.add(wrapper1);
	
	// Create stored label.
	storedCache = Math.round(storage.getkWattHourStored() *10.0)/10.0;;
	storedLabel = new WebLabel(
			Msg.getString("BuildingPanelPowerStorage.stored"), //$NON-NLS-1$
			WebLabel.CENTER);
	springPanel.add(storedLabel);
	
	WebPanel wrapper2 = new WebPanel(new FlowLayout(0, 0, FlowLayout.LEADING));
	storedTF = new WebTextField(storedCache + kWh);
	storedTF.setEditable(false);
	storedTF.setColumns(7);
	storedTF.setPreferredSize(new Dimension(120, 25));
	wrapper2.add(storedTF);
	springPanel.add(wrapper2);
	
	SpringUtilities.makeCompactGrid(springPanel,
               2, 2, 			//rows, cols
               75, 10,        //initX, initY
               3, 1);       //xPad, yPad
}
 
Example 11
Source File: TabPanelAttribute.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;

		// Create attribute label panel.
		WebPanel attributeLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(attributeLabelPanel);

		// Create attribute label
		WebLabel attributeLabel = new WebLabel(Msg.getString("TabPanelAttribute.label"), WebLabel.CENTER); //$NON-NLS-1$
		attributeLabel.setFont(new Font("Serif", Font.BOLD, 16));
		attributeLabelPanel.add(attributeLabel);

		// Create attribute scroll panel
		WebScrollPane attributeScrollPanel = new WebScrollPane();
//		attributeScrollPanel.setBorder(new MarsPanelBorder());
		centerContentPanel.add(attributeScrollPanel);

		// Create attribute table model
		if (person != null)
			attributeTableModel = new AttributeTableModel(person);
		else
			attributeTableModel = new AttributeTableModel(robot);
		
		// Create attribute table
		attributeTable = new ZebraJTable(attributeTableModel); //new JTable(attributeTableModel);//
		attributeTable.setPreferredScrollableViewportSize(new Dimension(225, 100));
		attributeTable.getColumnModel().getColumn(0).setPreferredWidth(100);
		attributeTable.getColumnModel().getColumn(1).setPreferredWidth(70);
		attributeTable.setRowSelectionAllowed(true);
//		attributeTable.setDefaultRenderer(Integer.class, new NumberCellRenderer());
		
		attributeScrollPanel.setViewportView(attributeTable);

		attributeTable.setAutoCreateRowSorter(true);
 
		// Align the content to the center of the cell
        // Note: DefaultTableCellRenderer does NOT work well with nimrod
		DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		renderer.setHorizontalAlignment(SwingConstants.LEFT);
		attributeTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
		attributeTable.getColumnModel().getColumn(1).setCellRenderer(renderer);

        TableStyle.setTableStyle(attributeTable);
        update();
        
        //attributeTableModel.update();
	}
 
Example 12
Source File: BuildingPanelResourceProcessing.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor.
	 * @param processor the resource processing building this panel is for.
	 * @param desktop The main desktop.
	 */
	public BuildingPanelResourceProcessing(ResourceProcessing processor, MainDesktopPane desktop) {

		// Use BuildingFunctionPanel constructor
		super(processor.getBuilding(), desktop);

		// Initialize variables.
		this.processor = processor;

		// Set layout
		setLayout(new BorderLayout());

		// Prepare resource processes label
		// 2014-11-21 Changed font type, size and color and label text
		// 2014-11-21 Added internationalization for labels
		WebLabel resourceProcessesLabel = new WebLabel(Msg.getString("BuildingPanelResourceProcessing.title"), WebLabel.CENTER);
		resourceProcessesLabel.setFont(new Font("Serif", Font.BOLD, 16));
		//resourceProcessesLabel.setForeground(new Color(102, 51, 0)); // dark brown
		add(resourceProcessesLabel, BorderLayout.NORTH);

		WebLabel supportedProcessesLabel = new WebLabel(Msg.getString("BuildingPanelResourceProcessing.supportedProcesses"), WebLabel.CENTER);
		add(supportedProcessesLabel, BorderLayout.CENTER);

		// Get all processes at building.
		List<ResourceProcess> processes = processor.getProcesses();
		int size = processes.size();
		// Prepare resource processes list panel.
//		WebPanel resourceProcessesListPanel = new WebPanel(new GridLayout(processes.size(), 2, 10, 3));
//		resourceProcessesListPanel.setBorder(new EmptyBorder(3, 20, 3, 20)); //(int top, int left, int bottom, int right)
		//resourceProcessesListPanel.setOpaque(false);
		//resourceProcessesListPanel.setBackground(new Color(0,0,0,128));

		WebTextArea processesTA = new WebTextArea();
		processesTA.setEditable(false);
		processesTA.setFont(new Font("SansSerif", Font.ITALIC, 12));
		processesTA.setColumns(12);

		// For each specialty, add specialty name panel.
		for (ResourceProcess p : processes) {
			processesTA.append(" " + p.getProcessName()+ " ");
			if (!p.equals(processes.get(size-1)))
				//if it's NOT the last one
				processesTA.append("\n");
			
//			if (p.isProcessRunning()) {
//				processLabel.setIcon(greenDot);
//				processLabel.setToolTipText(p.getProcessName() + " process is running.");
//			}
//			else {
//				processLabel.setIcon(redDot);
//				processLabel.setToolTipText(p.getProcessName() + " process is not running.");
//			}
			
		}

		WebPanel listPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		listPanel.add(processesTA);
		processesTA.setBorder(new MarsPanelBorder());
//		resourceProcessesListPanel.setBorder(new MarsPanelBorder());
//		listPanel.add(resourceProcessesListPanel);
		add(listPanel, BorderLayout.SOUTH);
		//listPanel.setOpaque(false);
		//listPanel.setBackground(new Color(0,0,0,128));

		// Load green and red dots.
//		greenDot = new ImageIcon("images/GreenDot.png", "Process is running.");
//		redDot = new ImageIcon("images/RedDot.png", "Process is not running");

		// For each resource process, add a label.
//		processLabels = new ArrayList<WebLabel>(processes.size());
//		Iterator<ResourceProcess> i = processes.iterator();
//		while (i.hasNext()) {
//			ResourceProcess process = i.next();
//			WebLabel processLabel = new WebLabel(process.getProcessName(), WebLabel.LEFT);
//			//processLabel.setForeground(Color.DARK_GRAY);
//			//processLabel.setBackground(Color.WHITE);
//			processLabel.setFont(new Font("SansSerif", Font.ITALIC, 12));
//
//			if (process.isProcessRunning()) {
//				processLabel.setIcon(greenDot);
//				processLabel.setToolTipText(process.getProcessName() + " process is running.");
//			}
//			else {
//				processLabel.setIcon(redDot);
//				processLabel.setToolTipText(process.getProcessName() + " process is not running.");
//			}
//
////			resourceProcessesListPanel.add(processLabel);
//			processLabels.add(processLabel);
//		}
	}
 
Example 13
Source File: LaboratoryTabPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;

		Lab lab = rover.getLab();
		
		// Prepare laboratory panel
		WebPanel laboratoryPanel = new WebPanel(new BorderLayout());
		topContentPanel.add(laboratoryPanel);
		
		// Prepare name panel
		WebPanel titlePanel = new WebPanel();
		laboratoryPanel.add(titlePanel, BorderLayout.NORTH);

		// Prepare laboratory label
		WebLabel titleLabel = new WebLabel("Laboratory", WebLabel.CENTER);
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		titlePanel.add(titleLabel);
		
		// Prepare the top panel using spring layout.
		WebPanel springPanel = new WebPanel(new SpringLayout());
//		springPanel.setPadding(10, 0, 0, 0);
		laboratoryPanel.add(springPanel, BorderLayout.CENTER);
		
		// Prepare label panel
//		WebPanel labelPanel = new WebPanel(new GridLayout(3, 1));
//		laboratoryPanel.add(labelPanel, BorderLayout.CENTER);

		// Prepare researcher number label
		WebLabel headerLabel0 = new WebLabel("Number of Researchers : ", WebLabel.CENTER);
		springPanel.add(headerLabel0);
		
		researchersCache = lab.getResearcherNum();
		researchersLabel = new WebLabel("" + researchersCache, WebLabel.CENTER);
		springPanel.add(researchersLabel);

		// Prepare researcher capacityLabel
		WebLabel headerLabel1 = new WebLabel("Researcher Capacity : ", WebLabel.CENTER);
		springPanel.add(headerLabel1);
		
		WebLabel researcherCapacityLabel = new WebLabel("" + lab.getLaboratorySize(),
				WebLabel.CENTER);
		springPanel.add(researcherCapacityLabel);

        // Lay out the spring panel.
     	SpringUtilities.makeCompactGrid(springPanel,
     		                                2, 2, //rows, cols
     		                               90, 10,        //initX, initY
    		                               10, 4);       //xPad, yPad
				
		// Get the research specialties of the building.
		ScienceType[] specialties = lab.getTechSpecialties();
		int size = specialties.length;
		
		// Prepare specialty text area
		WebTextArea specialtyTA = new WebTextArea();
		specialtyTA.setEditable(false);
		specialtyTA.setFont(new Font("SansSerif", Font.ITALIC, 12));
		specialtyTA.setColumns(10);
//		specialtyTA.setSize(100, 60);
		specialtyTA.setBorder(new MarsPanelBorder());
		
		
		WebPanel listPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		listPanel.setSize(150, 80);
		listPanel.add(specialtyTA);
		
		TitledBorder titledBorder = BorderFactory.createTitledBorder(null, "Specialties",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new Font("Serif", Font.BOLD, 14), java.awt.Color.darkGray);
		listPanel.setBorder(titledBorder);
		
		// Prepare specialties label
//		WebLabel specialtiesLabel = new WebLabel("Specialties : ", WebLabel.CENTER);
//		listPanel.add(specialtiesLabel, BorderLayout.NORTH);		
		laboratoryPanel.add(listPanel, BorderLayout.SOUTH);
		
		// For each specialty, add specialty name panel.
		for (ScienceType specialty : specialties) {
			specialtyTA.append(" " + specialty.getName()+ " ");
			if (!specialty.equals(specialties[size-1]))
				//if it's NOT the last one
				specialtyTA.append("\n");
		}
	}
 
Example 14
Source File: TabPanelBots.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(titlePane);

		WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelBots.title"), WebLabel.CENTER); //$NON-NLS-1$
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		// titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
		titlePane.add(titleLabel);

		// Create robot count panel
		WebPanel countPanel = new WebPanel(new GridLayout(3, 1, 0, 0));
//		countPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(countPanel);

		// Create robot num label
		robotNumCache = settlement.getNumBots();
		robotNumLabel = new WebLabel(Msg.getString("TabPanelBots.associated", robotNumCache), WebLabel.CENTER); // $NON-NLS-1$
		countPanel.add(robotNumLabel);

		// Create robot indoor label
		robotIndoorCache = settlement.getNumBots();
		robotIndoorLabel = new WebLabel(Msg.getString("TabPanelBots.indoor", robotIndoorCache),
				WebLabel.CENTER); // $NON-NLS-1$
		countPanel.add(robotIndoorLabel);
		
		// Create robot capacity label
		robotCapacityCache = settlement.getRobotCapacity();
		robotCapLabel = new WebLabel(Msg.getString("TabPanelBots.capacity", robotCapacityCache), WebLabel.CENTER); // $NON-NLS-1$
		countPanel.add(robotCapLabel);

		// Create spring layout robot display panel
		WebPanel robotDisplayPanel = new WebPanel(new SpringLayout());// FlowLayout(FlowLayout.LEFT));
//		robotDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(robotDisplayPanel);

		// Create scroll panel for robot list.
		robotScrollPanel = new WebScrollPane();
		robotScrollPanel.setPreferredSize(new Dimension(120, 250));
		robotDisplayPanel.add(robotScrollPanel);

		// Create robot list model
		robotListModel = new RobotListModel(settlement);

		// Create robot list
		robotList = new JList<Robot>(robotListModel);
		robotList.addMouseListener(this);
		robotScrollPanel.setViewportView(robotList);

		// Create robot monitor button
		WebButton monitorButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelBots.tooltip.monitor")); //$NON-NLS-1$

		WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
//		buttonPane.setPreferredSize(new Dimension(25, 25));
		buttonPane.add(monitorButton);
		
		robotDisplayPanel.add(buttonPane);
		
		// Lay out the spring panel.
		SpringUtilities.makeCompactGrid(robotDisplayPanel, 2, 1, // rows, cols
				30, 10, // initX, initY
				10, 10); // xPad, yPad
	}
 
Example 15
Source File: TabPanelCrew.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		// Prepare title label.
		WebPanel titlePanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		WebLabel titleLabel = new WebLabel(Msg.getString("TabPanelCrew.title"), WebLabel.CENTER); //$NON-NLS-1$
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		titlePanel.add(titleLabel);
		topContentPanel.add(titlePanel);

		// Create crew count panel
		WebPanel crewCountPanel = new WebPanel(new GridLayout(2, 1, 0, 0));
//		crewCountPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(crewCountPanel);

		// Create crew num label
		crewNumCache = crewable.getCrewNum();
		crewNumLabel = new WebLabel(Msg.getString("TabPanelCrew.crew", crewNumCache), WebLabel.CENTER); //$NON-NLS-1$
		crewCountPanel.add(crewNumLabel);

		// Create crew capacity label
		crewCapacityCache = crewable.getCrewCapacity();
		crewCapLabel = new WebLabel(Msg.getString("TabPanelCrew.crewCapacity", crewCapacityCache), WebLabel.CENTER); //$NON-NLS-1$
		crewCountPanel.add(crewCapLabel);

		// Create crew display panel
		WebPanel crewDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.LEFT));
//		crewDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(crewDisplayPanel);

		// Create scroll panel for crew list.
		WebScrollPane crewScrollPanel = new WebScrollPane();
		crewScrollPanel.setPreferredSize(new Dimension(175, 200));
		crewDisplayPanel.add(crewScrollPanel);

		// Create crew list model
		crewListModel = new DefaultListModel<Person>();
		//crewListModel = new DefaultListModel<Unit>();
		crewCache = crewable.getCrew();
		//crewCache = crewable.getUnitCrew();
		Iterator<Person> i = crewCache.iterator();
		//Iterator<Unit> i = crewCache.iterator();
		while (i.hasNext()) crewListModel.addElement(i.next());

		// Create crew list
		crewList = new JList<Person>(crewListModel);
		//crewList = new JList<Unit>(crewListModel);
		crewList.addMouseListener(this);
		crewScrollPanel.setViewportView(crewList);

		// Create crew monitor button
		WebButton monitorButton = new WebButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelCrew.tooltip.monitor")); //$NON-NLS-1$
		crewDisplayPanel.add(monitorButton);
	}
 
Example 16
Source File: TabPanelMaintenance.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
		 * Constructor.
		 * 
		 * @param building the building to display.
		 */
		public BuildingMaintenancePanel(Building building) {
			// User WebPanel constructor.
			super();

			manager = building.getMalfunctionManager();

			setLayout(new GridLayout(4, 1, 0, 0));
//			setBorder(new MarsPanelBorder());

			WebLabel buildingLabel = new WebLabel(building.getNickName(), WebLabel.LEFT);
			buildingLabel.setFont(new Font("Serif", Font.BOLD, 14));
			add(buildingLabel);

			// Add wear condition cache and label.
			wearConditionCache = (int) Math.round(manager.getWearCondition());
			wearConditionLabel = new WebLabel(
					Msg.getString("BuildingPanelMaintenance.wearCondition", wearConditionCache),
					WebLabel.CENTER);
			TooltipManager.setTooltip(wearConditionLabel, 
					Msg.getString("BuildingPanelMaintenance.wear.toolTip"),
					TooltipWay.down);
			// wearConditionLabel.setMargin (4);
//			add(wearConditionLabel);

			WebPanel mainPanel = new WebPanel(new BorderLayout(0, 0));
			add(mainPanel);

			lastCompletedCache = (int) (manager.getTimeSinceLastMaintenance() / 1000D);
			lastLabel = new WebLabel("Last completed : " + lastCompletedCache + " sols ago", WebLabel.LEFT);
			mainPanel.add(lastLabel, BorderLayout.WEST);
			// lastLabel.setToolTipText(getToolTipString());
			TooltipManager.setTooltip(lastLabel, getToolTipString(), TooltipWay.down);

			// Prepare progress bar panel.
			WebPanel progressBarPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
//			mainPanel.add(progressBarPanel, BorderLayout.CENTER);
			add(progressBarPanel);
			
			mainPanel.add(wearConditionLabel, BorderLayout.CENTER);
			
			// Prepare progress bar.
			JProgressBar progressBar = new JProgressBar();
			progressBarModel = progressBar.getModel();
			progressBar.setStringPainted(true);
			progressBar.setPreferredSize(new Dimension(240, 15));
			progressBarPanel.add(progressBar);

			// Set initial value for progress bar.
			double completed = manager.getMaintenanceWorkTimeCompleted();
			double total = manager.getMaintenanceWorkTime();
			int percentDone = (int) (100D * (completed / total));
			progressBarModel.setValue(percentDone);

			// Prepare parts label.
			Map<Integer, Integer> parts = manager.getMaintenanceParts();
			partsLabel = new WebLabel(getPartsString(parts, false), WebLabel.CENTER);
			partsLabel.setPreferredSize(new Dimension(-1, -1));
			add(partsLabel);

			TooltipManager.setTooltip(partsLabel, getPartsString(parts, false), TooltipWay.down);
		}
 
Example 17
Source File: TabPanelMaintenance.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		// Create topPanel.
		WebPanel topPanel = new WebPanel(new GridLayout(2, 1));
		centerContentPanel.add(topPanel);

		// Create maintenance panel.
		WebPanel maintenancePanel = new WebPanel(new BorderLayout());
		topPanel.add(maintenancePanel);

		// Create maintenance label.
		WebLabel titleLabel = new WebLabel("Building Maintenance", WebLabel.CENTER);
		titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
		// titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
		maintenancePanel.add(titleLabel, BorderLayout.NORTH);

		// Create scroll pane for maintenance list panel.
		maintenanceScrollPane = new WebScrollPane();
		// increase vertical mousewheel scrolling speed for this one
		maintenanceScrollPane.getVerticalScrollBar().setUnitIncrement(16);
		maintenanceScrollPane.setPreferredSize(new Dimension(200, 75));
		maintenancePanel.add(maintenanceScrollPane, BorderLayout.CENTER);

		// Prepare maintenance list panel.
		maintenanceListPanel = new WebPanel(new GridLayout(0, 1, 0, 0));
//		maintenanceListPanel.setBorder(new MarsPanelBorder());
		maintenanceScrollPane.setViewportView(maintenanceListPanel);
		populateMaintenanceList();

		// Create malfunctions panel.
		WebPanel malfunctionsPanel = new WebPanel(new BorderLayout());
		topPanel.add(malfunctionsPanel);

		// Create malfunctions label.
		WebLabel malfunctionsLabel = new WebLabel("Building Malfunctions", WebLabel.CENTER);
		malfunctionsLabel.setFont(new Font("Serif", Font.BOLD, 16));
		// malfunctionsLabel.setForeground(new Color(102, 51, 0)); // dark brown
		malfunctionsPanel.add(malfunctionsLabel, BorderLayout.NORTH);

		// Create scroll panel for malfunctions list panel.
		malfunctionsScrollPane = new WebScrollPane();
		// increase vertical mousewheel scrolling speed for this one
		malfunctionsScrollPane.getVerticalScrollBar().setUnitIncrement(16);
		malfunctionsScrollPane.setPreferredSize(new Dimension(200, 75));
		malfunctionsPanel.add(malfunctionsScrollPane, BorderLayout.CENTER);

		// Prepare malfunctions outer list panel.
		WebPanel malfunctionsOuterListPanel = new WebPanel(new BorderLayout(0, 0));
//		malfunctionsOuterListPanel.setBorder(new MarsPanelBorder());
		malfunctionsScrollPane.setViewportView(malfunctionsOuterListPanel);

		// Prepare malfunctions list panel.
		malfunctionsListPanel = new WebPanel();
		malfunctionsListPanel.setLayout(new BoxLayout(malfunctionsListPanel, BoxLayout.Y_AXIS));
		malfunctionsOuterListPanel.add(malfunctionsListPanel, BorderLayout.NORTH);

		populateMalfunctionsList();
	}
 
Example 18
Source File: TypePanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor.
	 * @param wizard {@link CreateMissionWizard} the create mission wizard.
	 */
	@SuppressWarnings("unchecked")
	TypePanel(CreateMissionWizard wizard) {
		// Use WizardPanel constructor.
		super(wizard);
		
		this.wizard = wizard;
		
		missionManager = Simulation.instance().getMissionManager();
		
		// Set the layout.
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		
		// Set the border.
		setBorder(new MarsPanelBorder());
		
		// Create the type info label.
		WebLabel typeInfoLabel = new WebLabel("Select Mission Type");
		typeInfoLabel.setFont(typeInfoLabel.getFont().deriveFont(Font.BOLD));
		typeInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
		add(typeInfoLabel);
		
		// Create the type panel.
		WebPanel typePane = new WebPanel(new FlowLayout(FlowLayout.LEFT));
		typePane.setAlignmentX(Component.LEFT_ALIGNMENT);
		add(typePane);
		
		// Create the type label.
		WebLabel typeLabel= new WebLabel("Type: ");
		typePane.add(typeLabel);
		
		// Create the mission types.
		MissionType[] missionTypes = MissionDataBean.getMissionTypes();
//		sortStringBubble(missionTypes);
//		MissionType[] displayMissionTypes = new MissionType[missionTypes.length];
		List<String> types = new ArrayList<>();
		int size = missionTypes.length;
		for (int i=0; i<size; i++) {
			types.add(missionTypes[i].getName());
		}
//		displayMissionTypes[0] = "";
//        System.arraycopy(missionTypes, 0, displayMissionTypes, 1, missionTypes.length);
		typeSelect = new JComboBoxMW<String>();
		Iterator<String> k = types.iterator();
		while (k.hasNext()) 
			typeSelect.addItem(k.next());
		typeSelect.setSelectedIndex(-1);
		
		typeSelect.addItemListener(this);

        typeSelect.setMaximumRowCount(typeSelect.getItemCount());
		typePane.add(typeSelect);
		typePane.setMaximumSize(new Dimension(Short.MAX_VALUE, typeSelect.getPreferredSize().height));
		
		// Add a vertical strut to separate the display.
		add(Box.createVerticalStrut(10));
		
		// Create the description info label.
		descriptionInfoLabel = new WebLabel("Edit Mission Description (Optional)");
		descriptionInfoLabel.setFont(descriptionInfoLabel.getFont().deriveFont(Font.BOLD));
		descriptionInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
		descriptionInfoLabel.setEnabled(false);
		add(descriptionInfoLabel);
		
		// Create the description panel.
		WebPanel descriptionPane = new WebPanel(new FlowLayout(FlowLayout.LEFT));
		descriptionPane.setAlignmentX(Component.LEFT_ALIGNMENT);
		add(descriptionPane);
		
		// Create the description label.
		descriptionLabel = new WebLabel("Description: ");
		descriptionLabel.setEnabled(false);
		descriptionPane.add(descriptionLabel);
		
		// Create the description text field.
		descriptionTF = new WebTextField(20);
		descriptionTF.setEnabled(false);
		descriptionPane.add(descriptionTF);
		descriptionPane.setMaximumSize(new Dimension(Short.MAX_VALUE, descriptionTF.getPreferredSize().height));

		// Listen for changes in the text
		addChangeListener(descriptionTF, e -> {
			  descriptionText = descriptionTF.getText();
//			  System.out.println("descriptionText: " + descriptionText);
		});
		
		// Add a vertical glue.
		add(Box.createVerticalGlue());
	}
 
Example 19
Source File: TabPanelAssociatedPeople.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(titlePane);

		// Create associated people label
		WebLabel heading = new WebLabel(Msg.getString("TabPanelAssociatedPeople.title"), WebLabel.CENTER); //$NON-NLS-1$
		heading.setFont(new Font("Serif", Font.BOLD, 16));
		// heading.setForeground(new Color(102, 51, 0)); // dark brown
		titlePane.add(heading);

		// Prepare count spring layout panel.
		WebPanel countPanel = new WebPanel(new SpringLayout());//GridLayout(3, 1, 0, 0));
//		countPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(countPanel);

		// Create associate label
		WebLabel populationNumHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.associated"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationNumHeader);
		
		populationCitizensCache = settlement.getNumCitizens();
		populationCitizensLabel = new WebLabel(populationCitizensCache + "", WebLabel.LEFT);
		countPanel.add(populationCitizensLabel);

		// Create population indoor label
		WebLabel populationIndoorHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.indoor"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationIndoorHeader);
		
		populationIndoorCache = settlement.getIndoorPeopleCount();
		populationIndoorLabel = new WebLabel(populationIndoorCache + "", WebLabel.LEFT);
		countPanel.add(populationIndoorLabel);
		
		// Create population capacity label
		WebLabel populationCapacityHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.capacity"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationCapacityHeader);
		
		populationCapacityCache = settlement.getPopulationCapacity();
		populationCapacityLabel = new WebLabel(populationCapacityCache + "", WebLabel.RIGHT);
		countPanel.add(populationCapacityLabel);
		
		// Lay out the spring panel.
		SpringUtilities.makeCompactGrid(countPanel, 3, 2, // rows, cols
				25, 10, // initX, initY
				10, 10); // xPad, yPad
		
        UIManager.getDefaults().put("TitledBorder.titleColor", Color.darkGray);
        Border lowerEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder title = BorderFactory.createTitledBorder(lowerEtched, " " + Msg.getString("TabPanelAssociatedPeople.title") + " ");
//      title.setTitleJustification(TitledBorder.RIGHT);
        Font titleFont = UIManager.getFont("TitledBorder.font");
        title.setTitleFont( titleFont.deriveFont(Font.ITALIC + Font.BOLD));
        
		// Create spring layout population display panel
		WebPanel populationDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		populationDisplayPanel.setBorder(title);
//		populationDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(populationDisplayPanel);

		// Create scroll panel for population list.
		populationScrollPanel = new WebScrollPane();
		populationScrollPanel.setPreferredSize(new Dimension(200, 250));
		populationDisplayPanel.add(populationScrollPanel);

		// Create population list model
		populationListModel = new AssociatedPopulationListModel(settlement);

		// Create population list
		populationList = new JList<Person>(populationListModel);
		populationList.addMouseListener(this);
		populationScrollPanel.setViewportView(populationList);


		// Create population monitor button
		JButton monitorButton = new JButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelAssociatedPeople.tooltip.monitor")); //$NON-NLS-1$
		populationDisplayPanel.add(monitorButton);
		
//		WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.RIGHT));
////		buttonPane.setPreferredSize(new Dimension(25, 25));
//		buttonPane.add(monitorButton);
//		
//		populationDisplayPanel.add(buttonPane);

	}
 
Example 20
Source File: TabPanelCredit.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		// Prepare credit label panel.
		WebPanel creditLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(creditLabelPanel);

		// Prepare credit label.
		WebLabel creditLabel = new WebLabel(Msg.getString("TabPanelCredit.label"), WebLabel.CENTER); //$NON-NLS-1$
		creditLabel.setFont(new Font("Serif", Font.BOLD, 16));
		//creditLabel.setForeground(new Color(102, 51, 0)); // dark brown
		creditLabelPanel.add(creditLabel);

		// Create scroll panel for the outer table panel.
		WebScrollPane creditScrollPanel = new WebScrollPane();
		creditScrollPanel.setPreferredSize(new Dimension(280, 280));
		centerContentPanel.add(creditScrollPanel);

		// Prepare credit table model.
		CreditTableModel creditTableModel = new CreditTableModel((Settlement) unit);

		// Prepare credit table.
		creditTable = new ZebraJTable(creditTableModel);
		creditScrollPanel.setViewportView(creditTable);
		creditTable.setRowSelectionAllowed(true);
		
		creditTable.setDefaultRenderer(Double.class, new NumberCellRenderer(2, true));
		
		creditTable.getColumnModel().getColumn(0).setPreferredWidth(100);
		creditTable.getColumnModel().getColumn(1).setPreferredWidth(120);
		creditTable.getColumnModel().getColumn(2).setPreferredWidth(50);
		
		// Added the two methods below to make all heatTable columns
		// Resizable automatically when its Panel resizes
		creditTable.setPreferredScrollableViewportSize(new Dimension(225, -1));
		//creditTable.setAutoResizeMode(WebTable.AUTO_RESIZE_ALL_COLUMNS);
		// Added sorting
		creditTable.setAutoCreateRowSorter(true);

		// Align the preference score to the center of the cell
		DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		renderer.setHorizontalAlignment(SwingConstants.RIGHT);
		creditTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
//		creditTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
		creditTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
		
		TableStyle.setTableStyle(creditTable);

	}