classdef JonPagelsProjectGUI < matlab.apps.AppBase
    properties (Access = public)
        UIFigure                     matlab.ui.Figure
        GridLayout                   matlab.ui.container.GridLayout
        LeftPanel                    matlab.ui.container.Panel
        EditField                    matlab.ui.control.NumericEditField
        NumberofEngineCylindersButtonGroup  matlab.ui.container.ButtonGroup
        Button_8                     matlab.ui.control.RadioButton
        Button_6                     matlab.ui.control.RadioButton
        Button_4                     matlab.ui.control.RadioButton
        TrailerTowedButtonGroup      matlab.ui.container.ButtonGroup
        NoButton                     matlab.ui.control.RadioButton
        YesButton                    matlab.ui.control.RadioButton
        FuelTypeButtonGroup          matlab.ui.container.ButtonGroup
        DieselButton                 matlab.ui.control.RadioButton
        GasolineButton               matlab.ui.control.RadioButton
        TripinmilesEditField         matlab.ui.control.NumericEditField
        TripinmilesEditFieldLabel    matlab.ui.control.Label
        TrailerWeightEditField       matlab.ui.control.NumericEditField
        TrailerWeightEditFieldLabel  matlab.ui.control.Label
        costpergallonSlider          matlab.ui.control.Slider
        costpergallonSliderLabel     matlab.ui.control.Label
        CenterPanel                  matlab.ui.container.Panel
        PlotButton                   matlab.ui.control.Button
        CalculateButton              matlab.ui.control.Button
        RightPanel                   matlab.ui.container.Panel
        costmileEditField            matlab.ui.control.NumericEditField
        costmileEditFieldLabel       matlab.ui.control.Label
        CosttofuelupEditField        matlab.ui.control.NumericEditField
        CosttofuelupEditFieldLabel   matlab.ui.control.Label
        GallonsofusedfuelEditField   matlab.ui.control.NumericEditField
        GallonsofusedfuelEditFieldLabel  matlab.ui.control.Label
        MilesGallonEditField         matlab.ui.control.NumericEditField
        MilesGallonEditFieldLabel    matlab.ui.control.Label
        UIAxes                       matlab.ui.control.UIAxes
    properties (Access = private)
    methods (Access = private)
        function costpergallonSliderValueChanged(app, event)
            c = app.costpergallonSlider.Value;
        function FuelTypeButtonGroupSelectionChanged(app, event)
            F=app.FuelTypeButtonGroup.SelectedObject;
        function NumberofEngineCylindersButtonGroupSelectionChanged(app, event)
            C = app.NumberofEngineCylindersButtonGroup.SelectedObject;
        function TrailerWeightEditFieldValueChanged(app, event)
            TW = app.TrailerWeightEditField.Value;            
        function TripinmilesEditFieldValueChanged(app, event)
            M = app.TripinmilesEditField.Value;            
        function CalculateButtonPushed(app, event)
            M = app.TripinmilesEditField.Value; 
            TW = app.TrailerWeightEditField.Value; 
            F=app.FuelTypeButtonGroup.SelectedObject;
            T = app.TrailerTowedButtonGroup.SelectedObject;
                                fprintf('exceedes truck weight limit ');
                            elseif TW>2000 && TW<=4000
                                fprintf('exceedes truck weight limit ');
                            elseif TW>2000 && TW<=4000
                            elseif TW>4000 && TW<=6000
                            elseif TW>6000 && TW<=8000
                                fprintf('exceedes truck weight limit ');
                    elseif TW>2000 && TW<=4000
                        fprintf('exceedes truck weight limit ');
                    elseif TW>2000 && TW<=4000
                    elseif TW>4000 && TW<=6000
                    elseif TW>6000 && TW<=8000
                        fprintf('exceedes truck weight limit ');
                    elseif TW>2000 && TW<=4000
                    elseif TW>4000 && TW<=6000
                    elseif TW>6000 && TW<=8000
                    elseif TW>8000 && TW<10000
                        fprintf('exceedes truck weight limit ');
    app.MilesGallonEditField.Value=mpg;
    app.GallonsofusedfuelEditField.Value=G;
    app.costmileEditField.Value=CM;
    app.CosttofuelupEditField.Value=CF;
function TrailerTowedButtonGroupSelectionChanged(app, event)
T = app.TrailerTowedButtonGroup.SelectedObject;
function MilesGallonEditFieldValueChanged(app, event)
app.MilesGallonEditField.Value=mpg;
function GallonsofusedfuelEditFieldValueChanged(app, event)
app.GallonsofusedfuelEditField.Value=G;
function CosttofuelupEditFieldValueChanged(app, event)
app.CosttofuelupEditField.Value=CF;
function costmileEditFieldValueChanged(app, event)
app.costmileEditField.Value=CM;
function updateAppLayout(app, event)
currentFigureWidth = app.UIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
    app.GridLayout.RowHeight = {517, 517, 517};
    app.GridLayout.ColumnWidth = {'1x'};
    app.CenterPanel.Layout.Row = 1;
    app.CenterPanel.Layout.Column = 1;
    app.LeftPanel.Layout.Row = 2;
    app.LeftPanel.Layout.Column = 1;
    app.RightPanel.Layout.Row = 3;
    app.RightPanel.Layout.Column = 1;
elseif (currentFigureWidth > app.onePanelWidth && currentFigureWidth <= app.twoPanelWidth)
    app.GridLayout.RowHeight = {517, 517};
    app.GridLayout.ColumnWidth = {'1x', '1x'};
    app.CenterPanel.Layout.Row = 1;
    app.CenterPanel.Layout.Column = [1,2];
    app.LeftPanel.Layout.Row = 2;
    app.LeftPanel.Layout.Column = 1;
    app.RightPanel.Layout.Row = 2;
    app.RightPanel.Layout.Column = 2;
    app.GridLayout.RowHeight = {'1x'};
    app.GridLayout.ColumnWidth = {475, '1x', 378};
    app.LeftPanel.Layout.Row = 1;
    app.LeftPanel.Layout.Column = 1;
    app.CenterPanel.Layout.Row = 1;
    app.CenterPanel.Layout.Column = 2;
    app.RightPanel.Layout.Row = 1;
    app.RightPanel.Layout.Column = 3;
methods (Access = private)
function createComponents(app)
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.AutoResizeChildren = 'off';
app.UIFigure.Position = [100 100 970 517];
app.UIFigure.Name = 'MATLAB App';
app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
app.GridLayout = uigridlayout(app.UIFigure);
app.GridLayout.ColumnWidth = {475, '1x', 378};
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = 'on';
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.ForegroundColor = [1 0 0];
app.LeftPanel.BackgroundColor = [0.8 0.8 0.8];
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
app.costpergallonSliderLabel = uilabel(app.LeftPanel);
app.costpergallonSliderLabel.HorizontalAlignment = 'right';
app.costpergallonSliderLabel.FontColor = [1 0.4118 0.1608];
app.costpergallonSliderLabel.Position = [5 39 83 22];
app.costpergallonSliderLabel.Text = 'cost per gallon';
app.costpergallonSlider = uislider(app.LeftPanel);
app.costpergallonSlider.Limits = [2 7.5];
app.costpergallonSlider.MajorTicks = [2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5];
app.costpergallonSlider.ValueChangedFcn = createCallbackFcn(app, @costpergallonSliderValueChanged, true);
app.costpergallonSlider.FontColor = [1 0.4118 0.1608];
app.costpergallonSlider.Position = [109 48 352 3];
app.costpergallonSlider.Value = 2;
app.TrailerWeightEditFieldLabel = uilabel(app.LeftPanel);
app.TrailerWeightEditFieldLabel.HorizontalAlignment = 'right';
app.TrailerWeightEditFieldLabel.FontColor = [0.6353 0.0784 0.1843];
app.TrailerWeightEditFieldLabel.Position = [5 176 79 22];
app.TrailerWeightEditFieldLabel.Text = 'Trailer Weight';
app.TrailerWeightEditField = uieditfield(app.LeftPanel, 'numeric');
app.TrailerWeightEditField.Limits = [0 12000];
app.TrailerWeightEditField.ValueDisplayFormat = '%.0f';
app.TrailerWeightEditField.ValueChangedFcn = createCallbackFcn(app, @TrailerWeightEditFieldValueChanged, true);
app.TrailerWeightEditField.FontColor = [0.6353 0.0784 0.1843];
app.TrailerWeightEditField.Position = [99 176 100 22];
app.TripinmilesEditFieldLabel = uilabel(app.LeftPanel);
app.TripinmilesEditFieldLabel.HorizontalAlignment = 'right';
app.TripinmilesEditFieldLabel.FontColor = [0 0.4471 0.7412];
app.TripinmilesEditFieldLabel.Position = [268 176 69 22];
app.TripinmilesEditFieldLabel.Text = 'Trip in miles';
app.TripinmilesEditField = uieditfield(app.LeftPanel, 'numeric');
app.TripinmilesEditField.ValueChangedFcn = createCallbackFcn(app, @TripinmilesEditFieldValueChanged, true);
app.TripinmilesEditField.FontColor = [0 0.4471 0.7412];
app.TripinmilesEditField.Position = [352 176 100 22];
app.FuelTypeButtonGroup = uibuttongroup(app.LeftPanel);
app.FuelTypeButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @FuelTypeButtonGroupSelectionChanged, true);
app.FuelTypeButtonGroup.Title = 'Fuel Type';
app.FuelTypeButtonGroup.BackgroundColor = [1 0 0];
app.FuelTypeButtonGroup.Position = [40 405 123 76];
app.GasolineButton = uiradiobutton(app.FuelTypeButtonGroup);
app.GasolineButton.Text = 'Gasoline';
app.GasolineButton.Position = [11 30 69 22];
app.GasolineButton.Value = true;
app.DieselButton = uiradiobutton(app.FuelTypeButtonGroup);
app.DieselButton.Text = 'Diesel';
app.DieselButton.Position = [11 8 65 22];
app.TrailerTowedButtonGroup = uibuttongroup(app.LeftPanel);
app.TrailerTowedButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @TrailerTowedButtonGroupSelectionChanged, true);
app.TrailerTowedButtonGroup.Title = 'Trailer Towed';
app.TrailerTowedButtonGroup.BackgroundColor = [1 1 0];
app.TrailerTowedButtonGroup.Position = [285 405 123 76];
app.YesButton = uiradiobutton(app.TrailerTowedButtonGroup);
app.YesButton.Text = 'Yes';
app.YesButton.Position = [11 30 58 22];
app.YesButton.Value = true;
app.NoButton = uiradiobutton(app.TrailerTowedButtonGroup);
app.NoButton.Text = 'No';
app.NoButton.Position = [11 8 65 22];
app.NumberofEngineCylindersButtonGroup = uibuttongroup(app.LeftPanel);
app.NumberofEngineCylindersButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @NumberofEngineCylindersButtonGroupSelectionChanged, true);
app.NumberofEngineCylindersButtonGroup.Title = 'Number of Engine Cylinders';
app.NumberofEngineCylindersButtonGroup.BackgroundColor = [0.6353 0.0784 0.1843];
app.NumberofEngineCylindersButtonGroup.Position = [143 248 167 106];
app.Button_4 = uiradiobutton(app.NumberofEngineCylindersButtonGroup);
app.Button_4.Position = [11 60 58 22];
app.Button_4.Value = true;
app.Button_6 = uiradiobutton(app.NumberofEngineCylindersButtonGroup);
app.Button_6.Position = [11 38 65 22];
app.Button_8 = uiradiobutton(app.NumberofEngineCylindersButtonGroup);
app.Button_8.Position = [11 16 65 22];
app.EditField = uieditfield(app.LeftPanel, 'numeric');
app.EditField.Position = [186 72 167 22];
app.CenterPanel = uipanel(app.GridLayout);
app.CenterPanel.Layout.Row = 1;
app.CenterPanel.Layout.Column = 2;
app.CalculateButton = uibutton(app.CenterPanel, 'push');
app.CalculateButton.ButtonPushedFcn = createCallbackFcn(app, @CalculateButtonPushed, true);
app.CalculateButton.BackgroundColor = [1 0.0745 0.651];
app.CalculateButton.Position = [8 383 100 23];
app.CalculateButton.Text = 'Calculate';
app.PlotButton = uibutton(app.CenterPanel, 'push');
app.PlotButton.Position = [8 136 100 23];
app.PlotButton.Text = 'Plot';
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 3;
app.UIAxes = uiaxes(app.RightPanel);
title(app.UIAxes, 'mpg vs. cost per mile')
app.UIAxes.Position = [6 54 316 195];
app.MilesGallonEditFieldLabel = uilabel(app.RightPanel);
app.MilesGallonEditFieldLabel.BackgroundColor = [0 0 1];
app.MilesGallonEditFieldLabel.HorizontalAlignment = 'right';
app.MilesGallonEditFieldLabel.Position = [96 468 74 22];
app.MilesGallonEditFieldLabel.Text = 'Miles /Gallon';
app.MilesGallonEditField = uieditfield(app.RightPanel, 'numeric');
app.MilesGallonEditField.ValueChangedFcn = createCallbackFcn(app, @MilesGallonEditFieldValueChanged, true);
app.MilesGallonEditField.BackgroundColor = [0 0 1];
app.MilesGallonEditField.Position = [185 468 100 22];
app.GallonsofusedfuelEditFieldLabel = uilabel(app.RightPanel);
app.GallonsofusedfuelEditFieldLabel.BackgroundColor = [1 0.4118 0.1608];
app.GallonsofusedfuelEditFieldLabel.HorizontalAlignment = 'right';
app.GallonsofusedfuelEditFieldLabel.Position = [96 413 111 22];
app.GallonsofusedfuelEditFieldLabel.Text = 'Gallons of used fuel';
app.GallonsofusedfuelEditField = uieditfield(app.RightPanel, 'numeric');
app.GallonsofusedfuelEditField.ValueChangedFcn = createCallbackFcn(app, @GallonsofusedfuelEditFieldValueChanged, true);
app.GallonsofusedfuelEditField.BackgroundColor = [1 0.4118 0.1608];
app.GallonsofusedfuelEditField.Position = [222 413 100 22];
app.CosttofuelupEditFieldLabel = uilabel(app.RightPanel);
app.CosttofuelupEditFieldLabel.BackgroundColor = [0 1 0];
app.CosttofuelupEditFieldLabel.HorizontalAlignment = 'right';
app.CosttofuelupEditFieldLabel.Position = [96 362 82 22];
app.CosttofuelupEditFieldLabel.Text = 'Cost to fuel up';
app.CosttofuelupEditField = uieditfield(app.RightPanel, 'numeric');
app.CosttofuelupEditField.ValueChangedFcn = createCallbackFcn(app, @CosttofuelupEditFieldValueChanged, true);
app.CosttofuelupEditField.BackgroundColor = [0 1 0];
app.CosttofuelupEditField.Position = [193 362 100 22];
app.costmileEditFieldLabel = uilabel(app.RightPanel);
app.costmileEditFieldLabel.BackgroundColor = [0.4941 0.1843 0.5569];
app.costmileEditFieldLabel.HorizontalAlignment = 'right';
app.costmileEditFieldLabel.Position = [96 307 52 22];
app.costmileEditFieldLabel.Text = 'cost/mile';
app.costmileEditField = uieditfield(app.RightPanel, 'numeric');
app.costmileEditField.ValueChangedFcn = createCallbackFcn(app, @costmileEditFieldValueChanged, true);
app.costmileEditField.BackgroundColor = [0.4941 0.1843 0.5569];
app.costmileEditField.Position = [163 307 100 22];
app.UIFigure.Visible = 'on';
methods (Access = public)
function app = JonPagelsProjectGUI
registerApp(app, app.UIFigure)