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

The following examples show how to use com.alee.laf.label.WebLabel#setPreferredSize() . 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: 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 2
Source File: TabPanelMaintenance.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
		 * Constructor.
		 * 
		 * @param malfunction the malfunction for the panel.
		 * @param building    the building the malfunction is in.
		 */
		public BuildingMalfunctionPanel(Malfunction malfunction, Building building) {
			// Use WebPanel constructor
			super();

			// Initialize data members
			this.malfunction = malfunction;

			// Set layout and border.
			setLayout(new GridLayout(5, 1, 0, 0));
//			setBorder(new MarsPanelBorder());

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

			// Prepare the malfunction label.
			malfunctionLabel = new WebLabel(malfunction.getName(), WebLabel.LEFT);
			malfunctionLabel.setForeground(Color.red);
			add(malfunctionLabel);

			workLabel = new WebLabel("", WebLabel.LEFT);
//			workLabel.setFont(new Font("Serif", Font.ITALIC, 12));
//			workLabel.setForeground(Color.LIGHT_GRAY);
//			workLabel.setBackground(Color.DARK_GRAY);
			add(workLabel);
			
			// Progress bar panel.
			WebPanel progressBarPanel = new WebPanel(new BorderLayout(0, 0));
			add(progressBarPanel, BorderLayout.CENTER);

			// Prepare progress bar.
			JProgressBar progressBar = new JProgressBar();
			progressBarModel = progressBar.getModel();
			progressBar.setStringPainted(true);
			progressBarPanel.add(progressBar, BorderLayout.CENTER);

			// Set initial value for repair progress bar.
			progressBarModel.setValue(0);

			// Prepare parts label.
			partsLabel = new WebLabel(getPartsString(malfunction.getRepairParts(), false), WebLabel.CENTER);
			partsLabel.setPreferredSize(new Dimension(-1, -1));
			add(partsLabel);

			// Add tooltip.
//			setToolTipText(getToolTipString());
			TooltipManager.setTooltip(this, getToolTipString(), TooltipWay.up);
			
			update();
		}
 
Example 3
Source File: MalfunctionPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructs a MalfunctionPanel object with a name prefix.
	 * @param malfunction the malfunction to display
	 */
	public MalfunctionPanel(Malfunction malfunction) {

		// Call JPanel constructor.
		super();

		// Initialize data members.
		this.malfunction = malfunction;

		// Set layout
		setLayout(new GridLayout(3, 1, 0, 0));

		// Set border
		setBorder(new MarsPanelBorder());
		setOpaque(false);
		setBackground(new Color(0,0,0,128));

		// Prepare name label.
		nameLabel = new WebLabel(malfunction.getName(), WebLabel.CENTER);
		if (!malfunction.isEmergencyRepairDone()) {
			nameLabel.setText(malfunction.getName() + " - Emergency");
			nameLabel.setForeground(Color.red);
		}
		add(nameLabel);

		// Prepare repair pane.
		WebPanel repairPane = new WebPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
		add(repairPane);

		// Prepare repair progress bar.
		WebProgressBar repairBar = new WebProgressBar();
		repairBarModel = repairBar.getModel();
		repairBar.setStringPainted(true);
		repairPane.add(repairBar);

		// Set initial value for repair progress bar.
//		double totalRequiredWork = malfunction.getEmergencyWorkTime() + malfunction.getGeneralWorkTime()
//				+ malfunction.getEVAWorkTime();
//		double totalCompletedWork = malfunction.getCompletedEmergencyWorkTime() +
//				malfunction.getCompletedGeneralWorkTime() + malfunction.getCompletedEVAWorkTime();
//		int percentComplete = 0;
//		if (totalRequiredWork > 0D) percentComplete = (int) (100D * (totalCompletedWork / totalRequiredWork));
		repairBarModel.setValue((int)malfunction.getPercentageFixed());

		// Prepare repair parts label.
		partsLabel = new WebLabel(getPartsString(), WebLabel.CENTER);
		partsLabel.setPreferredSize(new Dimension(-1, -1));
		add(partsLabel);

		// Add tooltip.
		setToolTipText(getToolTipString());
	}
 
Example 4
Source File: CommanderWindow.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void createMissionPanel() {
		WebPanel panel = new WebPanel(new BorderLayout());
		tabPane.add(MISSION_TAB, panel);
	     
		policyMainPanel = new WebPanel(new BorderLayout());
		panel.add(policyMainPanel, BorderLayout.NORTH);
		policyMainPanel.setPreferredSize(new Dimension(200, 125));
		policyMainPanel.setMaximumSize(new Dimension(200, 125));
		
		// Create a button panel
		WebPanel buttonPanel = new WebPanel(new GridLayout(4,1));
//		buttonPanel.setPreferredSize(new Dimension(250, 120));
		policyMainPanel.add(buttonPanel, BorderLayout.CENTER);
		
		buttonPanel.setBorder(BorderFactory.createTitledBorder("Trade With Other Settlements"));
		buttonPanel.setToolTipText("Select the trade policy with other settlements");
		
		ButtonGroup group0 = new ButtonGroup();
		ButtonGroup group1 = new ButtonGroup();
	
		r0 = new JRadioButton("Can initiate Trading Mission", true);
		r1 = new JRadioButton("Cannot initiate Trading Mission");

		// Set up initial conditions
		if (settlement.isMissionDisable(Trade.DEFAULT_DESCRIPTION)) {
			r0.setSelected(false);
			r1.setSelected(true);
		}
		else {
			r0.setSelected(true);
			r1.setSelected(false);
		}
			
		r2 = new JRadioButton("No Trading Missions from all settlements");
		r3 = new JRadioButton(ALLOW);

		// Set up initial conditions
		boolean noTrading = true;
		if (settlement.isTradeMissionAllowedFromASettlement(settlement)) {
			List<Settlement> list = getOtherSettlements();
//			List<Settlement> allowedSettlements = settlementMissionList.getCheckedValues();
			for (Settlement s: list) {
				if (!settlement.isTradeMissionAllowedFromASettlement(s)) {
					noTrading = false;
					break;
				}
			}
		}
		
		WebLabel selectLabel = new WebLabel(" Choose :");
		selectLabel.setMinimumSize(new Dimension(150, 25));
		selectLabel.setPreferredSize(150, 25);
		
		innerPanel = new WebPanel(new BorderLayout());
		innerPanel.add(selectLabel, BorderLayout.NORTH);
		
		// Set settlement check boxes
		settlementMissionList = new WebCheckBoxList<>(StyleId.checkboxlist, createModel(getOtherSettlements()));
		settlementMissionList.setVisibleRowCount(3);
		innerPanel.add(settlementMissionList, BorderLayout.CENTER);
		
		WebScrollPane = new WebScrollPane(innerPanel);
		WebScrollPane.setMaximumWidth(250);

		
//		mainPanel.add(WebScrollPane, BorderLayout.EAST);
		
		if (noTrading) {			
			r2.setSelected(true);
			r3.setSelected(false);
			policyMainPanel.remove(WebScrollPane);
			policyMainPanel.add(emptyPanel, BorderLayout.EAST);
//			settlementMissionList.setEnabled(false);
		}
		else {
			r2.setSelected(false);
			r3.setSelected(true);
			r3.setText(ALLOW + SEE_RIGHT);
			policyMainPanel.remove(emptyPanel);
			policyMainPanel.add(WebScrollPane, BorderLayout.EAST);
//			settlementMissionList.setEnabled(true);
		}
		
		group0.add(r0);
		group0.add(r1);
		group1.add(r2);
		group1.add(r3);
		
		buttonPanel.add(r0);
		buttonPanel.add(r1);
		buttonPanel.add(r2);
		buttonPanel.add(r3);
		
		PolicyRadioActionListener actionListener = new PolicyRadioActionListener();
		r0.addActionListener(actionListener);
		r1.addActionListener(actionListener);
		r2.addActionListener(actionListener);
		r3.addActionListener(actionListener);

	}